Jump to content

Uploading Files?


Man In Tan

Recommended Posts

   	 ini_set('upload_max_filesize', 128*1024*1024);        ini_set('post_max_size', 128*1024*1024);        move_uploaded_file($_FILES['userfile']['tmp_name'], $root.$_GET['file']);        print_r($_FILES);

I'm trying to upload a 4.6 MB file to my server using this code, but I keep getting errors. Can you see what I'm doing wrong? The error code I'm getting is "1", meaning that the file is too big. But I'm using ini_set() to allow files up to 128 MB, so that doesn't make sense. This is what print_r() has to say:

Array(    [userfile] => Array        (            [name] => Dragonaut OP FULL - Perfect Blue.mp3            [type] =>             [tmp_name] =>             [error] => 1            [size] => 0        ))

Link to comment
Share on other sites

I'm pretty sure you have to make those ini changes in your .ini file. By the time those ini_set calls are executed, the file should already have been uploaded or rejected. What you probably need is a technique that makes the configuration before the upload process begins. Maybe I'm wrong. Been a while since I've really looked into it.

Link to comment
Share on other sites

You can verify that by printing the array before using ini_set, and after. You'll notice they are the same. Using ini_set doesn't cause PHP to look at the upload again and figure out if it meets the new criteria, it has already processed the file.

Link to comment
Share on other sites

Well that's a pain, but I guess it makes sense. I can't modify php.ini remotely, so I guess adding uploading capabilities to my file manager isn't an option. Thanks a bunch, to both of you! :Happy:

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...