tg989 Posted May 21, 2007 Share Posted May 21, 2007 Basically when I upload a file, the temporary file that php/apache creates is there until the upload finishes, then it is instantly deleted! the information in the $_FILES array says that no errors were encountered, but when I do move_uploaded_file there is no file there. If I monitor the temporary directory (i have it set in php.ini to use a temp folder which the apache server has full read/write on) while i'm uploading a file (and before it completes) I can see the temporary file there as it is supposed to be -- then as soon as it finishes, its gone. :-\ I believe it is a permissions issue but I'm not sure. the uploads directory directory is 777. Here is a test script I use to verify uploads: <html> <head> </head> <body> <form action="upload.php" method="post" enctype="multipart/form-data" name="fileform"> <input name="testfile" type="file" /> <input name="submit" type="submit" value="submit" /> </form> <?php if ($_POST['submit'] == 'submit'){ echo "move_uploaded_file result: "; if (!move_uploaded_file( $_FILES['tmp_name'], '/usr/home/robert/uploads/' . $_FILES['name'])){ echo "problem!"; }else{ echo "good!"; } echo "<br>\$_FILES: "; print_r($_FILES); echo "<br>"; // try manual move $cmd = 'mv "' . $_FILES['testfile']['tmp_name'] . '" "/usr/home/robert/uploads/' . $_FILES['testfile']['name'] . '"'; exec($cmd, $output, $return); echo '<br>[ ' . $cmd . ' ] returned [ ' . $return . ' ]<br>'; } ?> </body> which returns: move_uploaded_file result: problem! $_FILES: Array ( [testfile] => Array ( [name] => MultiMeterD124.rar [type] => application/octet-stream [tmp_name] => /usr/home/robert/tmp/phpdnuOAu [error] => 0 [size] => 852461 ) ) [ mv "/usr/home/robert/tmp/phpdnuOAu" "/usr/home/robert/uploads/MultiMeterD124.rar" ] returned [ 0 ] So basically the move_uploaded_files doesn't work but using shell does... ?! if I don't do anything with the file it gets deleted right after the upload is done... ;0 Quote Link to comment https://forums.phpfreaks.com/topic/52401-solved-uploaded-files-dissapear-once-uploaded/ Share on other sites More sharing options...
trq Posted May 21, 2007 Share Posted May 21, 2007 You might try setting the sticky bit on the temp directory. chmod +t tempdir Quote Link to comment https://forums.phpfreaks.com/topic/52401-solved-uploaded-files-dissapear-once-uploaded/#findComment-258588 Share on other sites More sharing options...
papaface Posted May 21, 2007 Share Posted May 21, 2007 because you should be going: if (!move_uploaded_file( $_FILES['formfilename']['tmp_name'], '/usr/home/robert/uploads/' . $_FILES['formfilename']['name'])){ You need to use the name of the file input thing in your form. I think... Quote Link to comment https://forums.phpfreaks.com/topic/52401-solved-uploaded-files-dissapear-once-uploaded/#findComment-258589 Share on other sites More sharing options...
tg989 Posted May 21, 2007 Author Share Posted May 21, 2007 i totally forgot it was a 2d array, im such a dumbass Quote Link to comment https://forums.phpfreaks.com/topic/52401-solved-uploaded-files-dissapear-once-uploaded/#findComment-258610 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.