Hmmm... well, I'm not sure. I was having problems with my file uploader yesterday. Apparently there was a new php release at some point and you now have to declare all variables passed from one page to the resulting page (which is a good thing).
I don't know if this will help you at all, but here is my code for uploading a file. I have a bit in there to keep people from uploading .php files and it also numbers the file - gives each file the next number available in the directory where I am placing them:
File upload form:
<form name = "uploader" enctype = "MULTIPART/FORM-DATA" method = "post" action = "uploadres.php">
<table cellpadding = "5">
<tr><td><p class="profileentry">Photo:</p></td><td><input type = "file" name = "image"></td></tr>
<tr><td></td><td><input type = "submit" value = "Submit"></td></tr>
</table>
</form>
Resulting page:
<?php
// file which includes the connection strings and filepath
include("allmyconns.inc");
$photo_name = $FILES['image']['name'];
$photo = $FILES['image']['tmp_name'];
// next line for debugging purposes
//echo "Photo = $photo<BR>";
// if submitter uploaded a photo get next number for file(s)
if ($photo_name != ""){
// Open the directory
$dh = opendir($filepath);
if ($dh) {
$x = 0;
// Read each file
while (($dirfile = readdir($dh)) !== FALSE) {
// Skip any directory
if (!is_file("$filepath/$dirfile")) continue;
$x++;
}
closedir($dh);
} else {
echo "Error opening directory.";
}
$nextnum = $x+1;
// next line for debugging purposes
//echo "<BR>Next file num = $nextnum <BR><BR>";
$fileext = strstr($photo_name, '.');
if (($fileext == ".php") or ($fileext == ".PHP")) {
echo "<p>.php file uploads are not allowed.</p>";
exit;
}
$newfilename = "$nextnum$fileext";
//echo "New file1 name = $newfilename<BR><BR>";
copy("$photo", "$filepath$newfilename") or die ("Couldn't copy photo.");
} // end check and name photo
?>