Upload Problems

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jim
Forum Contributor
Posts: 238
Joined: Fri Apr 19, 2002 5:26 am
Location: Near Austin, Texas

Upload Problems

Post by Jim »

My Code:

Code: Select all

//Image Upload

if (is_uploaded_file($HTTP_POST_FILESї'userfile']ї'tmp_name'])) 
{ 
   copy($HTTP_POST_FILESї'userfile']ї'tmp_name'], "/home/www/aoe2/!scripts/filesubmission/temp/"); 
} 
else 
{ 
   echo "Possible file upload attack. Filename: " . $HTTP_POST_FILESї'userfile']ї'name']; 
   
}
My Error:

Possible file upload attack. Filename:

I can't get any upload scripts to work! Why not?

Here's the page:

http://www.aoe2.com/!scripts/filesubmission/index.php
chris12295
Forum Contributor
Posts: 113
Joined: Sun Jun 09, 2002 10:28 pm
Location: USA
Contact:

Post by chris12295 »

well i cant tell you why your script isnt working but i know this script does.

Code: Select all

if(isset($userfile)) {

if (!eregi('(.gif|.jpeg|.jpg)', $userfile)) {
$invalidPic = "Sorry, only GIF or JPG files  (with a .gif, .jpeg, or .jpg extention) can be accepted.";
exit;
}
if (ereg('.gif', $userfile)) {
$ext = '.gif';
}
elseif (ereg('.jpg', $userfile)) {
$ext = '.jpg';
}
elseif (ereg('.jpeg', $userfile)) {
$ext = '.jpeg';
}
$userfile_name = $newFileName . $ext;
if (copy ($userfile, "your/path/$userfile_name")) {
$message='hi';
}
}
else {
$message='no';
}
this script will only allow jpg gif and jpeg images to be uploaded. it will place them in your directory. If you need more help email me at chris12295@aol.com. Tell me if i helped :wink:
User avatar
roninblade
Forum Newbie
Posts: 21
Joined: Thu Jun 13, 2002 7:12 pm

Post by roninblade »

well, judging from the current error on your page
Warning: fopen("/www/aoe2/!scripts/filesubmission/pages/.php", "w") - Permission denied in /home/www/aoe2/!scripts/filesubmission/submit_go.php on line 31

Warning: Supplied argument is not a valid File-Handle resource in /home/www/aoe2/!scripts/filesubmission/submit_go.php on line 32
Possible <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>. Filename:
i would guess you haven't set the file permissions on the directory. chmod the directory to 777
Jim
Forum Contributor
Posts: 238
Joined: Fri Apr 19, 2002 5:26 am
Location: Near Austin, Texas

Post by Jim »

That error came because I left something out in the URL:

http://www.aoe2.com/!scripts/filesubmis ... p?map=none

And the upload script isn't working! There are no errors, but the file doesn't show up in the specified directory :(
Post Reply