Jump to content
  • Advertisement
Sign in to follow this  
Witchcraven

[web] File upload problem

This topic is 5452 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am writing a simple php script that allows uploads. However, when I check to see if there are any files in the $_FILES array, I get: Array ( ) I am submitting several other fields in the form, and they go through ok. Here is what my form is like: <form method=post action=upload.php type=enctype=multipart/form-data> <input type=hidden name=cat value=a> <input type=hidden name=numup value=1> <input type=hidden name=MAX_FILE_SIZE value=20000> <input type=file name=up0>
<input type=submit value=UPLOAD> </form> I have PHP 4.3.8 It simply doesnt work. In phpinfo, the upload values are: file_uploads On On upload_max_filesize 20M 20M upload_tmp_dir no value no value user_dir no value no value

Share this post


Link to post
Share on other sites
Advertisement
Try this correction:
<form method="post" action="upload.php" enctype="multipart/form-data">
<input type=hidden name=cat value=a>
<input type=hidden name=numup value=1>
<input type=hidden name=MAX_FILE_SIZE value=20000>
<input type=file name=up0>

<input type=submit value=UPLOAD>
</form>

Share this post


Link to post
Share on other sites
bah. Now I have to escape all those characters. I wish PHP was like perl in that it doesnt matter what character you use. I wonder why I just didnt use cgi.

Share this post


Link to post
Share on other sites
You can use a single or double quote for variables. Using double quotes is helpful as it automatically translates any variables you may have inside them. As for your code, what's in upload.php?

Share this post


Link to post
Share on other sites
Well, that didnt fix anything, but I got it working somehow. I put the MAX_FILE_SIZE as the first input, followed by the file, followed by the hidden, then submit. I also quoted the attributes where needed. Although in my experience html usually doesnt care if things are quoted. I have no idea why is works now.

It didnt work when I just quoted things.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Chmod the folder 777

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!