Forum Moderators: coopster

Message Too Old, No Replies

File uploading stopped working.

         

alexey9

2:01 pm on Sep 28, 2007 (gmt 0)

10+ Year Member



Hello guys,

About week ago file uploading stopped working on my server. It worked perfectly with my PHP script, but now it doesn't.

The problem is NOT in script, because I've tried simple one and it doesn't work too:

<?php
if(isset($_POST['submit'])){
$userdir = "/home/user/photos/";
$filein = $userdir . $_FILES['url']['name'];
copy($_FILES['url']['tmp_name'], $filein);
}
?>

<form action="up.php" method="post" enctype="multipart/form-data">
<p>
<b>Choose photo:</b>
<input name="url" type="file" /><br />
<input type="submit" name="submit" />
<input type="reset" />
</p></form>

Also, the problem is not in permissions as copy command works:

copy("/home/user/photos/1.jpg", "/home/user/photos/1111.jpg");

I have this lines in my php.ini (I didn't change anything from when it worked):

;;;;;;;;;;;;;;;;
; 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 =

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

PHP scripts do not print any error message (error reporting is On in php.ini and in script). Also, there is no any errors in log file.

I wonder how can I fix it? I killed few days on this and still can't understand why it stopped working.

joelgreen

3:17 pm on Sep 28, 2007 (gmt 0)

10+ Year Member



Any files left in default temp folder for uploaded files?

BTW, you do "copy". Maybe there are too much files in that folder? Do they get removed from time to time from temp folder?

Tip: why don't you use this php function? It is more secure.
move_uploaded_file

alexey9

4:10 pm on Sep 28, 2007 (gmt 0)

10+ Year Member



My temporary folder is /tmp

When I do "ls -a", I can't see any uploaded files.

Also, I've added this line into my PHP script:

print_r($_FILES);

I get this:

Array ( [url] => Array ( [name] => 1038515685_36c6fd93f7_o.jpg [type] => image/jpeg [tmp_name] => /tmp/php0MpikH [error] => 0 [size] => 513076 ) )

Does it mean file uploads into /tmp directory? Why I can't see it there then?

alexey9

4:13 pm on Sep 28, 2007 (gmt 0)

10+ Year Member



Tip: why don't you use this php function? It is more secure.
move_uploaded_file

Thanks, I will use it when I fix my problem. I didn't know there is special function for that.

joelgreen

4:56 pm on Sep 28, 2007 (gmt 0)

10+ Year Member



Try copying file just after you did print_r() from the /tmp folder to another folder. At least you'll know if it existed in /tmp

alexey9

6:01 pm on Sep 28, 2007 (gmt 0)

10+ Year Member



I do not know how but it was fixed. All I've changed is added this:

print_r($_FILES);
print "<br />";
system("ls /tmp/ -a");

I'm totally confused about this.