Forum Moderators: coopster

Message Too Old, No Replies

PHP upload

- file isn't uploaded

         

xt35

7:03 pm on Mar 12, 2008 (gmt 0)

10+ Year Member



Hi,

I'm having a small problem. I've made few tests for PHP upload and using the files below:

The PHP file (test.php):

<?php
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Stored in: " . $_FILES["file"]["tmp_name"];
}
?>

The HTML file

<html>
<body>
<form action="test.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>

I've chmod'ed the php file to 755, nothing is uploaded on the TMP folder (where I understand the files are uploaded).

Am I doing something wrong?

Thank you,
xt35

P.S. I'm using a Linux webhosting on Hostgator.

eelixduppy

7:39 pm on Mar 12, 2008 (gmt 0)



The file will be deleted from the temporary directory at the end of the request if it has not been moved away or renamed.

[php.net...]

You should be moving it appropriately to the location of your choice.

xt35

7:40 pm on Mar 12, 2008 (gmt 0)

10+ Year Member



FOLLOW UP:

Something weird. I've chmod'ed the upload directory to 777, and now I receive an error like: Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request

xt35

7:45 pm on Mar 12, 2008 (gmt 0)

10+ Year Member



Thank you eelixduppy, I've already tried that and received the following error:

Warning: move_uploaded_file(/public_html/aatest/AFile.txt) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/auser/public_html/aatest/test3.php on line 9

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpAQu8qN' to '/public_html/aatest/AFile.txt' in /home/auser/public_html/aatest/test3.php on line 9

eelixduppy

2:31 am on Mar 20, 2008 (gmt 0)



Have you resolved this issue yet? If not, maybe you want to post relevant code to see what's going on because it cannot find the correct temp file to copy it looks like. If you want to try a simple case, try the example in the link I have provided above and see where that gets you.