I have a page (links_form.php) with a list box and a file upload routine. The problem seems to be, when I upload a file and call this script, the list box does not update it's contents. My guess is the upload hasn't completed before the list is recreated. I'm guessing this because after an upload, if I refresh the page, the list generates with the newly uploaded file.
Is there a way to check that the upload is complete?
Thanks, DC
Here's the List Box...
$handle = opendir($icon_folder);
while ($images = readdir($handle)) {
if($images == "." Or $images == "..") {}
else {
$image[] = $images;
}
}
closedir($handle);
if ($img_selection == "") {
$img_selection = "select and image";
}
echo "
<select name=\"img_selection\" size=1 class=\"form_field_blackonwhite\">
<option value=\"$img_selection\">$img_selection</option>
<option value=\"\"> -- Clear Selection -- </option>
";
foreach($image as $image_sel){ $img_selection = $image_sel;
echo "<option value=\"$img_selection\">$truncd_name</option>
";
}
echo "
</select>
";
and here's the upload script on the same page...
echo"
<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" class=\"editortext\">
<span class=\"editortext\">File Name: </span>
<input type=file name=\"File\" Size=20 class=\"form_field_blackonwhite\">
<input type=submit name=\"submit\" value=\"Upload File\" class=\"buttonunselected\">
";
if(is_dir($icon_folder)) {} else {echo "<span class=\"editortext\">no destination folder</span>";}
if ($File) {
if (copy ($File, $icon_folder.$File_name)) {
echo "
<div style=\"text-align:center\">
<span class=\"alerttext\">$File_name, $File_size Bytes, was succesfully uploaded</span>
</div>";
}
else {
echo "<br><span class=\"editortext\">Your file - $File_name - could not be uploaded</span>"; # could not upload
}
unlink ($File);
} else { echo "<br><br>"; }
echo"
</form>";