Jump to content

[SOLVED] Uploaded files dissapear once uploaded.


tg989

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.