Jump to content

Archived

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

PupChow

Form uploaded file not showing up

Recommended Posts

I am having a hard time getting the form upload script to work and I need to once again turned to the gurus for help. Everything seems to be processing, there is a long pause as during the form process as if the file is being uploaded. The problem is when I check the "uploads" folder, the file is simply not there.

I made sure the form has: enctype="multipart/form-data"

I made sure the "uploads" folder has the necessary permission.

The input box is simply: <input name="Picture" type="file">


Is there any thing else that I am missing?


[code]
// ==============
// Configuration
// ==============
$uploaddir = "uploads"; // Where you want the files to upload to - Important: Make sure this folders permissions (CHMOD) is 0777!
// ==============
// Upload Part
// ==============
if(is_uploaded_file($_FILES['Picture']['tmp_name']))
{
move_uploaded_file($_FILES['Picture']['tmp_name'],$uploaddir.'/'.$_FILES['Picture']['name']);
}
print "Your file has been uploaded successfully! Yay!<br />";
[/code]

Share this post


Link to post
Share on other sites
Change:

[code]if(is_uploaded_file($_FILES['Picture']['tmp_name']))[/code]

to:

[code]if ($_FILES['Picture']['size'] > 0)[/code]

Share this post


Link to post
Share on other sites
Thanks! Unfortunately the file is still not showing up in the uploads folder. The file is definitely being uploaded though (there was a short pause).

Is there any way for it to display error msg?

Share this post


Link to post
Share on other sites
Just a little bit more info, I tried the upload code at PHP manual and got the following result:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
Possible file upload attack!
Here is some more debugging info:Array
(
[Picture] => Array
(
[name] => DrJohnson_Panda5.gif
[type] => image/gif
[tmp_name] => C:\PHP\uploadtemp\phpCD9D.tmp
[error] => 0
[size] => 25752
)

)

Entry successfully added.
[/quote]

The code is as followed:
[code]
$uploaddir = '/c:/hosting/webhost4life/member/mychow/uploads/';   //  I tried both /c: and c: //
$uploadfile = $uploaddir . basename($_FILES['Picture']['name']);

echo '<pre>';
if (move_uploaded_file($_FILES['Picture']['tmp_name'], $uploadfile)) {
   echo "File is valid, and was successfully uploaded.\n";
} else {
   echo "Possible file upload attack!\n";
}

echo 'Here is some more debugging info:';
print_r($_FILES);

print "</pre>";
[/code]

Share this post


Link to post
Share on other sites

×

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.