BleepingComputer.com: PHP file upload problem

Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

PHP file upload problem

#1 User is offline   Romeo29 

  • Learning To Bleep
  • PipPipPipPipPipPip
  • Find Topics
  • Group: BC Advisor
  • Posts: 2,814
  • Joined: 06-July 08
  • Gender:Not Telling
  • Location:127.0.0.1

Posted 12 February 2010 - 08:25 AM

Hi,
I wanted to make an admin page on my site so I can upload images using web admin interface and so that I don't have to go through FTP upload. Here is my stripped down code for uploading :

<form enctype="multipart/form-data" action="index.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Upload : <input name="picture" type="file" /><br />
<input type="submit" value="Upload" />
</form>


But the thing is that it does not work when I click Upload button. The $_POST and $_FILES variables are empty. I checked by using print_r($_POST) and print_r($_FILES). The result is that it prints only Array()

I Googled and found many people facing this problem but could not find any solution. I tested on WAMP on Windows Vista, then tested on Ubuntu but nothing works.

Please suggest me some solutions or other methods of uploading a file through web interface.
Thanks.
[url="http://www.avast.com/"]avast! free antivirus[/url]

#2 User is offline   groovicus 

  • Hail Groovicus!
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 9,522
  • Joined: 05-June 04
  • Gender:Male
  • Location:Centerville, SD

Posted 12 February 2010 - 10:48 AM

What is the name of the file that is supposed to be getting the image? Is it really index.php?
"Take the risk of thinking for yourself, much more happiness, truth, beauty, and wisdom will come to you that way" - Christopher Hitchens

#3 User is offline   Romeo29 

  • Learning To Bleep
  • PipPipPipPipPipPip
  • Find Topics
  • Group: BC Advisor
  • Posts: 2,814
  • Joined: 06-July 08
  • Gender:Not Telling
  • Location:127.0.0.1

Posted 12 February 2010 - 12:11 PM

Yes. I was testing on local server with that file name. I would change it to something else when uploading to actual web host.
[url="http://www.avast.com/"]avast! free antivirus[/url]

#4 User is offline   groovicus 

  • Hail Groovicus!
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 9,522
  • Joined: 05-June 04
  • Gender:Male
  • Location:Centerville, SD

Posted 12 February 2010 - 12:22 PM

Without seeing all of our code, I can't say for sure. My forms for file uploads are just like that, except I am using AJAX to do the uploads. All I could guess is that you have a syntax error somewhere.

EDIT: I lied (well, sort of). I am using the same form, but I am using a control from the YUI library that is handling the actual upload.
"Take the risk of thinking for yourself, much more happiness, truth, beauty, and wisdom will come to you that way" - Christopher Hitchens

#5 User is offline   Romeo29 

  • Learning To Bleep
  • PipPipPipPipPipPip
  • Find Topics
  • Group: BC Advisor
  • Posts: 2,814
  • Joined: 06-July 08
  • Gender:Not Telling
  • Location:127.0.0.1

Posted 12 February 2010 - 03:03 PM

Thanks groovicus for hinting at YUI library, its amazing :thumbsup:
[url="http://www.avast.com/"]avast! free antivirus[/url]

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users