View Full Version : php upload not working

02-20-2003, 09:32 PM
I know you've probably had this question asked multiple times, but I searched through the post and found nothing that helped.

I can't get a file to upload using php. I get no errors, just the file doesn't appear. I'm using Apache 1.3.26, PHP 4.2.2 on Windows 2000 Server. I've used other file system scripts such as read/write, dir listing. Here's the file upload part of my php.ini and the upload script. Thanks in advance.

php.ini :

; File Uploads ;

; Whether to allow HTTP file uploads.
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
upload_tmp_dir = C:\Fireserv\www\uploads

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M

upload.php :

<form enctype="multipart/form-data" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="3000000000000">
Send this file: <input name="userfile" type="file">
<input type="submit" value="Send File">

02-20-2003, 09:56 PM
is display_errors=on ?
and does folder "C:\Fireserv\www\uploads" exist?
Perhaps the problem is at code.
Submit your code :}

02-20-2003, 10:03 PM
Display errors is on and the directory des exist. I copied it from the windows address bar.

(Display full pathname in address bar is enabled)

02-20-2003, 10:28 PM
If that's all your php code for the upload, then I doubt it would work. You need to add upload directory paths etc into a script

02-20-2003, 11:54 PM
what variant are you using to access the file properties once it is uploaded? Showing the rest of your script would have helped a tad here...

$_FILE['userfile']['tmp_name'] ?
$userfile_type ?
$HTTP_POST_FILES['userfile']['name'] ?

02-21-2003, 12:51 AM
It works now. My problem is that when I browsed the tmp directory, there was nothing there. But now it seems to be fine.

Here's my code.

$file_dir = "c:\fireserv\www\uploads";
$file_url = "http://localhost/uploads";

foreach( $HTTP_POST_FILES as $file_name => $file_array ) {
print "path: ".$file_array['tmp_name']."<br>\n";
print "name: ".$file_array['name']."<br>\n";
print "type: ".$file_array['type']."<br>\n";
print "size: ".$file_array['size']."<br>\n";

if ( is_uploaded_file( $file_array['tmp_name'] ) ) {
move_uploaded_file( $file_array['tmp_name'], "$file_dir/$file_name")
or die ("Couldn't copy");
print "<a href=\"$file_url/$file_name\">$file_name</a>\n\n";
<form enctype="multipart/form-data" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="3000000000000">
<input name="fupload" type="file"><br>
<input type="submit" value="Send File">