Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.