Mike Lewis
Programmer
Hello All.
This is probably very simple, but I can't figure it out. In summary, this is what I want to achieve:
1. Display a form from which the user can upload a file.
2. Perform some checks on the uploaded file.
3. Display the results of those checks on the same page as the original form.
This is what I've got so far (highly simplified for the sake of clarity):
The form's action attribute points to a page named check.php, which consists simply of a call to a function named upload(). The function looks like this (again, highly simplified):
This all works fine, apart from one detail: The error / success message appears on a new page. Not surprising, given that check.php is a separate page from the original form.
What I want is for the message to appear on the same page as the original form. In other words, I don't want the user to have to navigate back to the previous page in order to repeat the upload.
Obviously, this must be possible, as I've seen this type of behaviour a million times, but I can't see how to do it. Any help greatly appreciated.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
My Visual FoxPro site: www.ml-consult.co.uk
This is probably very simple, but I can't figure it out. In summary, this is what I want to achieve:
1. Display a form from which the user can upload a file.
2. Perform some checks on the uploaded file.
3. Display the results of those checks on the same page as the original form.
This is what I've got so far (highly simplified for the sake of clarity):
Code:
<form enctype="multipart/form-data" action = "check.php"
method="post">
<input type = "hidden" name = "MAX_FILE_SIZE"
value = "50000" />
<p>File to upload:</p>
<input type = "file" name = "importfile" size = "50"
accept = "text/plain" />
<input type = "submit" value = "Upload Now" />
</form>
The form's action attribute points to a page named check.php, which consists simply of a call to a function named upload(). The function looks like this (again, highly simplified):
Code:
if ( .... the validation checks fail ...)
{ echo 'File is invalid; exit; }
else
{ echo 'Success'; }
This all works fine, apart from one detail: The error / success message appears on a new page. Not surprising, given that check.php is a separate page from the original form.
What I want is for the message to appear on the same page as the original form. In other words, I don't want the user to have to navigate back to the previous page in order to repeat the upload.
Obviously, this must be possible, as I've seen this type of behaviour a million times, but I can't see how to do it. Any help greatly appreciated.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
My Visual FoxPro site: www.ml-consult.co.uk