Webmaster Forums 101 - Free Help and Discussions
 
 
 

MEMBER REWARDS - Earn free advertising by participating in these forums! Click here for details.

Welcome to Webmaster Forums 101!

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

Reply
 
Thread Tools Search this Thread Display Modes
Old 3rd October 2003, 10:15 AM   #1
viper's Avatar

Username: viper
Rank: WF101 Fanatic
Join Date: Apr 2003
Location: Canada
Posts: 172
Points: 28.21
Default Need help with file uploading

I ben i need some help with a file upload script i can't seem to get it to work. I emailed my host and everything is enabled to allow file uploads threw php but everything i try won't work.

Here's my form i'm using.

Code:
<form method=\"post\" action=\"upload2.php\"> <p>Choose a screenshot to upload:</P> <p><input type=\"file\" name=\"file\" id=\"file\"></p> <p><input type=\"submit\" name=\"submit\" value=\"Upload\"></P> </form>

Here's the upload script i took it right from the php manual to test it out.

Code:
$uploaddir = '/home/viperweb/public_html/bobs/uploads/'; $uploadfile = $uploaddir . $_FILES['file']['name']; if(copy($_FILES['file']['tmp_name'], $uploadfile)) { print "File is valid, and was successfully uploaded."; } else { print "Possible file upload attack!"; }

All i get is either a blank screen or Possible file upload attack. It won't upload the file. I chmoded the folder to 777 and everthing i can think of but nothing will work.



Thanks


Viper
__________________
viper is offline   Reply With Quote
Old 3rd October 2003, 04:19 PM   #2
Mr. Tech's Avatar

Username: Mr. Tech
Rank: Problem Solver
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
Send a message via MSN to Mr. Tech
Default

Simple fix. You need to add this:

Code:
<form method=\"post\" action=\"upload2.php\" ENCTYPE="multipart/form-data">

And just incase your PHP for the upload doesn't work (I've never tried your way, use this:

Code:
<?php $uploaddir = '/home/viperweb/public_html/bobs/uploads/'; $uploadfile = $uploaddir . $_FILES['file']['name']; if(is_uploaded_file($_FILES['file']['tmp_name'])) { move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.$uploadfile); }?>

Hope that helps!
__________________
Please read the Forum Rules

Get rewarded for posting
- free advertising!

.::. [ Webmaster Resources ] .::. [ Web Design ] .::. [ Developer Tutorials ] .::.
Mr. Tech is offline   Reply With Quote
Old 3rd October 2003, 07:27 PM   #3
viper's Avatar

Username: viper
Rank: WF101 Fanatic
Join Date: Apr 2003
Location: Canada
Posts: 172
Points: 28.21
Default

thanks ben i feel like a moron now lol i new the part had to be in the form and thought it was in there lol.

I must be blind not seeing that lol.


Thanks again
__________________
viper is offline   Reply With Quote
Old 4th October 2003, 11:35 AM   #4
Mr. Tech's Avatar

Username: Mr. Tech
Rank: Problem Solver
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
Send a message via MSN to Mr. Tech
Default

Nah, you're still learning. I even forgot to put that in a couple of times :cheesygr:
__________________
Please read the Forum Rules

Get rewarded for posting
- free advertising!

.::. [ Webmaster Resources ] .::. [ Web Design ] .::. [ Developer Tutorials ] .::.
Mr. Tech is offline   Reply With Quote
Old 5th March 2004, 12:38 AM   #5

Username: buchard
Rank: WF101 Newbie
Join Date: Mar 2004
Posts: 6
Points: 0.00
Send a message via Yahoo to buchard
Default yupzzz....

It's all programmer's weakeness just like me too
Sometimes i forgot to write ENCTYPE="multipart/form-data" in form tag. but it's ok if you use this for submitting post data, not for upload
__________________
<b>Buchard</b>
buchard is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not 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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
File Swappers Moving Away From P2P Mr. Tech Software & Hardware Help 1 29th March 2005 06:00 PM
FTP thats right File Transfer Protocol USMCFR Software & Hardware Help 1 7th June 2004 03:06 PM
Uploading Images into database with line of text. mr t Server-Side Scripting & Databases 1 17th November 2003 07:42 AM
File Launches on server when clicked jpmiller@access.k12.wv.us Website Design & Coding 5 22nd October 2003 07:42 PM

Login
User Name
Password


Featured Members


Featured Links


Useful Resources
Webmaster Resources
Developers Tools
Developer Tutorials


Partners

All times are GMT +10. The time now is 09:39 AM.


Powered by vBulletin Version 3.5.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.3.2
 
 
WEBMASTER FORUMS 101
ARCHIVE
CONTACT US
TOP
   
© Webmaster Forums 101 2005. All Rights Reserved.
Design by: vBCore