Connecting Tech Pros Worldwide Help | Site Map

php file upload error

dave
Guest
 
Posts: n/a
#1: Jul 17 '05
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>" ;
}

?>


Pedro Graca
Guest
 
Posts: n/a
#2: Jul 17 '05

re: php file upload error


dave wrote:[color=blue]
> 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.[/color]

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.
[color=blue]
> And i'm not sure where to go as the server confirms
> file uploaded successfully. Any help appreciated.[/color]
[color=blue]
><?php
>
> if (count($_FILES))
> {
> var_dump($_FILES) ;
> }
>
> if (is_uploaded_file($_FILES['UploadFile']['tmp_name']))
> {[/color]

See these links:
http://www.php.net/move_uploaded_file
http://www.php.net/manual/en/features.file-upload.php
[color=blue]
> print "<h3>File successfully uploaded.</h3>" ;
> print "<a href=\"{$_SERVER['PHP_SELF']}\">Upload Another?<br>" ;
> }[/color]
<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!
Paul Barfoot
Guest
 
Posts: n/a
#3: Jul 17 '05

re: php file upload error


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" <dmehler26@woh.rr.com> wrote in message
news:1R4ud.59560$MG3.58092@fe2.columbus.rr.com...[color=blue]
> 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>" ;
> }
>
> ?>
>
>[/color]


Closed Thread


Similar PHP bytes