Jump to content


Photo

Form uploaded file not showing up


  • Please log in to reply
3 replies to this topic

#1 PupChow

PupChow
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 20 March 2006 - 02:34 AM

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?


// ==============
// 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 />";


#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 20 March 2006 - 02:44 AM

Change:

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

to:

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


#3 PupChow

PupChow
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 20 March 2006 - 03:04 AM

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?


#4 PupChow

PupChow
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 20 March 2006 - 03:32 AM

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:
$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>";





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users