I have a php form that allows users to upload an image to my server. On Submit, this form reloads the page and displays all uploaded images in the upload folder.
I have a second form on the page that I want to place the name of the uploaded file into. What is the best way to do this? I would rather not use a session solution because I think that requires cookies. Is there a way to read the file name in the variable the_file into a persistant variable before the page reloads. Or, when the page reloads and displays all of the images in the uploads folder, can I assign the last element returned to a field in the second form? Would this be reliable, what if 2 people submitted images at the same time?
Here is the function that creates the input form to upload the file:
function form($error=false)
{
print "
";
global $PHP_SELF,$my_max_file_size;
if ($error) print $error . "
";
print "\n";
print '
';
And here is the function that displays the files after a file is uploaded:
function list_files() {
global $the_path;
$handle = dir($the_path);
print "\nUploaded Pictures waiting to be placed online: ";
while ($file = $handle->read()) {
if (($file != ".") && ($file != "..")) {
print "\n" . $file . " ";
}
}
print "";
}
Or, can I display verification that the file uploaded without reloading the page(in other words, without submitting to self) and then assign the variable the_file to a field in the second form? Thank you for any help.
?Passing fform variable to 2nd form on same page??new
Brad
10-12-03 20:38?
?Reply To This Message
?Your Name:
?Your Email:
?Subject:
Email replies to this thread, to the address above.
??wrote: > > I have a php form that allows users to upload an image to my > server. On Submit, this form reloads the page and displays > all uploaded images in the upload folder. > > I have a second form on the page that I want to place the > name of the uploaded file into. What is the best way to do > this? I would rather not use a session solution because I > think that requires cookies. Is there a way to read the file > name in the variable the_file into a persistant variable > before the page reloads. Or, when the page reloads and > displays all of the images in the uploads folder, can I > assign the last element returned to a field in the second > form? Would this be reliable, what if 2 people submitted > images at the same time? > > Here is the function that creates the input form to upload > the file: > > function form($error=false) > { > print "
align='center'>
"; > global $PHP_SELF,$my_max_file_size; > > if ($error) print $error . "
"; > > > print "\n"; > print '
'; > > And here is the function that displays the files > after a file is uploaded: > > function list_files() { > > global $the_path; > > $handle = dir($the_path); > print "\nUploaded Pictures waiting to be placed > online: "; > while ($file = $handle->read()) { > if (($file != ".") && ($file != "..")) { > print "\n" . $file . " "; > } > } > print ""; > } > > Or, can I display verification that the file uploaded without > reloading the page(in other words, without submitting to > self) and then assign the variable the_file to a field in the > second form? Thank you for any help. > > brad ">??