home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 1865
Discussions: 188,398, Posts: 2,243,591, Members: 232,627
Old August 2nd, 2004, 06:06 PM   Digg it!   #1 (permalink)
Perfetc Member
 
VHockey86's Avatar
 
Join Date: Jan 2003
Location: Maryland Suburbia
Posts: 4,327
Upload script

I'm trying to impliment a system on a webpage where people can upload screenshots to a webserver. Kind of similar to how you can upload pictures to your photo gallary here at techimo by browsing and sending the file, but alot simpilar.

I tried using this page:
http://us3.php.net/manual/en/feature...ad.post-method
I put the little php script towards the bottom in a file and called it "upload.php" and uploaded it to my webserver. Then I put the form code into a normal web document called "upload.htm"
All I changed was the "_URL_" thing which it said to change to the location of the php script (which I did).
However I cant get the thing working.
It comes back with an error saying.

Code:
Possible file upload attack!  Here's some debugging info:
Array
(
    [userfile] => Array
        (
            [name] => perfect.gif
            [type] => image/gif
            [tmp_name] => /tmp/phpz0HdEk
            [error] => 0
            [size] => 4542
        )

)
Anyone know how I can impliment a system like this? My programing knowledge is slim to none so I'd need help there if scripts were neccesary.

If anyone has an entirely different approach to the link I posted above thats fine too, just as long as it works and is relatively secure.
I also want to be able to control where it uploads the files too... like what directory on the webserver. The webserver is at www.1and1.com so I dont have direct access to the server.

I managed to setup a phpBB and linked it to a mysql database, however there doesnt appear to be any direct access to the mysql so I dont know if thats a possibility. I tried beforehand on another project to create a "shoutbox" but I couldnt figure out how to run the .sql file that the tutorial told me to. Only thing I could figure was to login with SSH and try to run the file, but it just told me "permission denied".

If anyone has any ideas please lemme know.
thanks in advance for any help

Vhockey86

VHockey86 is offline   Reply With Quote
Old August 2nd, 2004, 06:16 PM     #2 (permalink)
Member
 
noseBleeD's Avatar
 
Join Date: Jun 2004
Location: usa
Posts: 250
Quote:
[tmp_name] => /tmp/phpz0HdEk
Does this refer to temporary filename given for the image that is being uploaded, and if so, should it be given a name with same extention (which shows that this hasn't been done), and should it go to tmp directory (do you have tmp directory)?

I don't have any other ideas, sorry.

noseBleeD is offline   Reply With Quote
Old August 2nd, 2004, 06:24 PM     #3 (permalink)
Perfetc Member
 
VHockey86's Avatar
 
Join Date: Jan 2003
Location: Maryland Suburbia
Posts: 4,327
Ya I created a /tmp/ directory on the server the first time I saw that error, still got the same thing. Not sure how it gets the name though. Everytime I run it, the part after "/tmp/php" changes.

VHockey86 is offline   Reply With Quote
Old August 2nd, 2004, 07:08 PM     #4 (permalink)
Member
 
noseBleeD's Avatar
 
Join Date: Jun 2004
Location: usa
Posts: 250
Do you have the move_uploaded_file function written in page, or did you not use that function?

with function:
Code:
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
without function:
Code:
if ($_FILES['userfile']['tmp_name'], $uploadfile) {
   print "File is valid, and was successfully uploaded. ";
   print_r($_FILES);
} else {
   print "Unable to Upload Fiile: \n";
   print_r($_FILES);
}
If that didn't help (probably didn't),
then do you have a size limit function that might be throwing away the upload?

Also from php script website:
Quote:
Warning

max_input_time sets the maximum time, in seconds, the script is allowed to receive input; this includes file uploads. For large or multiple files, or users on slower connections, the default of 60 seconds may be exceeded.

If post_max_size is set too small, large files cannot be uploaded. Make sure you set post_max_size large enough.

Not validating which file you operate on may mean that users can access sensitive information in other directories.

Please note that the CERN httpd seems to strip off everything starting at the first whitespace in the content-type mime header it gets from the client. As long as this is the case, CERN httpd will not support the file upload feature.

Due to the large amount of directory listing styles we cannot guarantee that files with exotic names (like containing spaces) are handled properly.

A developer may not mix normal input fields and file upload fields in the same form variable (by using an input name like foo[]).
#3: Not validating which file....
Maybe cause.

Last edited by noseBleeD : August 2nd, 2004 at 07:15 PM. Reason: added warning section from php script website
noseBleeD is offline   Reply With Quote
Old August 2nd, 2004, 08:04 PM     #5 (permalink)
Perfetc Member
 
VHockey86's Avatar
 
Join Date: Jan 2003
Location: Maryland Suburbia
Posts: 4,327
hmm, well I found this other gallery program at source forge and managed to get that installed (it did all the config pages via the browser, I just had to execute a shell script on the server to get it going).
http://s90390266.onlinehome.us/gallery/

Thx for the help though nosebleed, give me a second and i'll try the stuff that you posted just to see if it works.
VHockey86 is offline   Reply With Quote
Old August 2nd, 2004, 08:10 PM     #6 (permalink)
Perfetc Member
 
VHockey86's Avatar
 
Join Date: Jan 2003
Location: Maryland Suburbia
Posts: 4,327
hmm,
replaced the section of code that you gave me such that I had..
Code:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body><?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.

$uploaddir = '/';
$uploadfile = $uploaddir . $_FILES['userfile']['name'];

print "<pre>";
if ($_FILES['userfile']['tmp_name'], $uploadfile) {
   print "File is valid, and was successfully uploaded. ";
   print_r($_FILES);
} else {
   print "Unable to Upload Fiile: \n";
   print_r($_FILES);
}
print "</pre>";

?> 

</body>
</html>
but now it gave me the error
Parse error: parse error, unexpected ',' in /homepages/36/d90390248/htdocs/upload.php on line 16
Apparently without that initial function the syntax is all messed up

Last edited by VHockey86 : August 2nd, 2004 at 08:20 PM.
VHockey86 is offline   Reply With Quote
Old August 2nd, 2004, 08:49 PM     #7 (permalink)
Member
 
noseBleeD's Avatar
 
Join Date: Jun 2004
Location: usa
Posts: 250
seems like a needed function. oh well, thnx for trying it out.

I like just about everything on sourceforge.
Good and better choice!
Stick w/them there.
Great site.
Alot of good open source programs as well.
Cya
noseBleeD is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help With HTTP Uploading.... 311Sam Webmastering and Programming 8 August 10th, 2004 03:18 PM
A more exciting thread title! samwichse Linux and Unix 9 November 22nd, 2003 11:36 AM
vBulletin + PHP Damien019 Technical Support 2 April 16th, 2003 05:43 PM

Most Active Discussions
Is It Just Me? (2904)
Unarmed man on his stomach shot by .. (6)
3-days in and no threads about Gaza (161)
New Build ( Finally ) (6)
CPU wont boot (7)
Building a gaming computer advice (5)
I think I just killed my computer w.. (24)
Folderchat Weekday thread (444)
Upgrading RAM (6)
Recent Discussions
Left 4 Dead Small Freezes (3)
RCA 52Inch HDTV wont turn on (4)
wishin i could edit my aol prof.. (0)
For cheap price and good qualit.. (0)
Sporadic internet connectivity (2)
Assassins Creed PC Problems (40)
I think my PSU is dieing (1)
building a gaming computer, inp.. (0)
Iming and surfing slowed down (3)
Blackberry Storm, Gears of War .. (1)
Core 2 Quad Q9550 system (3)
COWBOOM Ripoff! Used Laptop w/$.. (4)


All times are GMT -4. The time now is 03:23 AM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28