By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,404 Members | 2,145 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,404 IT Pros & Developers. It's quick & easy.

php file upload error

P: n/a
Hello,
I'm trying to get the below script working, adapted from the manual on
php.net. Although i am getting success file uploading, i do not see the file
in the tempoary area. And i'm not sure where to go as the server confirms
file uploaded successfully. Any help appreciated.
Thanks.
Dave.

<?php

if (count($_FILES))
{
var_dump($_FILES) ;
}

if (is_uploaded_file($_FILES['UploadFile']['tmp_name']))
{
print "<h3>File successfully uploaded.</h3>" ;
print "<a href=\"{$_SERVER['PHP_SELF']}\">Upload Another?<br>" ;
}
else
{
print <<< __HTMLFORM__
<form enctype="multipart/form-data" action="{$_SERVER['PHP_SELF']}"
method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="10290000">
Filename: <input name="UploadFile" type="file">
<input type="submit" value="upload">
</form>
__HTMLFORM__;
print "<br><a href=\"{$_SERVER['PHP_SELF']}\">Upload Another?<br>" ;
}

?>
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
dave wrote:
I'm trying to get the below script working, adapted from the manual on
php.net. Although i am getting success file uploading, i do not see the file
in the tempoary area.
PHP automatically removes the uploaded file from the temporary directory
when the script ends. You have to put the file somewhere else while you
have control over it.
And i'm not sure where to go as the server confirms
file uploaded successfully. Any help appreciated. <?php

if (count($_FILES))
{
var_dump($_FILES) ;
}

if (is_uploaded_file($_FILES['UploadFile']['tmp_name']))
{
See these links:
http://www.php.net/move_uploaded_file
http://www.php.net/manual/en/features.file-upload.php
print "<h3>File successfully uploaded.</h3>" ;
print "<a href=\"{$_SERVER['PHP_SELF']}\">Upload Another?<br>" ;
}

<snip>

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Jul 17 '05 #2

P: n/a
Hi Dave

From the PHP Help file - handling file uploads section:

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

use copy($userfile, "/place/to/put/uploaded/file");

or similar to move the file (or just rename it), then you will be able to
see it.

--
Paul Barfoot
"dave" <dm*******@woh.rr.com> wrote in message
news:1R*******************@fe2.columbus.rr.com...
Hello,
I'm trying to get the below script working, adapted from the manual on
php.net. Although i am getting success file uploading, i do not see the
file
in the tempoary area. And i'm not sure where to go as the server confirms
file uploaded successfully. Any help appreciated.
Thanks.
Dave.

<?php

if (count($_FILES))
{
var_dump($_FILES) ;
}

if (is_uploaded_file($_FILES['UploadFile']['tmp_name']))
{
print "<h3>File successfully uploaded.</h3>" ;
print "<a href=\"{$_SERVER['PHP_SELF']}\">Upload Another?<br>" ;
}
else
{
print <<< __HTMLFORM__
<form enctype="multipart/form-data" action="{$_SERVER['PHP_SELF']}"
method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="10290000">
Filename: <input name="UploadFile" type="file">
<input type="submit" value="upload">
</form>
__HTMLFORM__;
print "<br><a href=\"{$_SERVER['PHP_SELF']}\">Upload Another?<br>" ;
}

?>

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.