Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
0 user currently in Programming. | 3 guests
Acmlm's Board - I2 Archive - Programming - PHP - Can't upload big files
  
User name:
Password:
Reply:
 

UserPost
mekakame
Posts: 18/18
I think there are both post_max_size and also upload_max_filesize too.
PHP will only accept first .......... of data in post method.
Thay's what I think.
HyperLamer
Posts: 8007/8210
You mean the MAX_FILE_SIZE field? It's supposed to tell the browser what size is allowed (though it doesn't seem to do much). Of course it could be spoofed pretty easy, so I don't rely on its value being correct when the form is submitted.
mekakame
Posts: 17/18
Does this also?

C:\Windows\php.ini, Line 372
; Maximum size of POST data that PHP will accept.
post_max_size = 8M


And your code:
<form name="ul" enctype="multipart/form-data" action="upload.php" method="POST">


As you see, it was also send in post method
Boom.dk
Posts: 392/392
To me, nothing looks unneccesary in HH's script. It all has its use.
Narf
Posts: 93/100
Originally posted by Santa Claus
Er... what exactly does that do differently than mine?
Shouldn't be any major differences, but mine just looks cleaner and doesn't have a shitload of unnecesary lines, variables and definitions so it's easier to trace bugs in it, would they occur. =)
Boom.dk
Posts: 388/392
Nothing as far as I can tell... If you got FTP access to your webspace, you should make a script that uploads with FTP instead of the traditional way.

For more information:
http://www.php.net/manual/en/ref.ftp.php
HyperLamer
Posts: 7791/8210
Er... what exactly does that do differently than mine?
Narf
Posts: 92/100
Try using the script I posted in this thread, be sure to change the 50 to 50000 though if you want to upload 50 MB files.
HyperLamer
Posts: 7713/8210
<?php
$MAX_FILE_SIZE = 50 * 1024 * 1024; //50MB
ini_set("upload_max_filesize",$MAX_FILE_SIZE); //Normally uploads >2MB will fail
ini_set("max_input_time",300);

if(!$function_php) include "function.php";

if($_FILES['file']['name'])
{
$Debug = $_POST['debug'];
$Notify = $_POST['notify'];
$Path = stripslashes($_POST['path']);
$FNAME = $_FILES['file']['name'];
//Make sure the file isn''t too big
if($_FILES['file']['size'] > $MAX_FILE_SIZE)
echo "File must be less than " . $MAX_FILE_SIZE . " bytes<br>";
else
{
if(move_uploaded_file($_FILES['file']['tmp_name'],$Path . "/" . $FNAME))
{
$UL_SUCCESS = true;
WriteAdminLog("Uploaded file: '" . $FNAME . "' (" . $_FILES['file']['size'] . " bytes) to " . $Path);
echo "Uploaded '" . $_FILES['file']['name'] . "' (" . $_FILES['file']['size'] . " bytes) as <a href=\"" . $Path . "/" . $FNAME . "\">" . $FNAME . "</a><br>";
}
else
{
$UL_SUCCESS = false;
WriteAdminLog("Upload failed: " . $_FILES['file']['name'] . "(" . $_FILES['file']['size'] . " bytes)");
echo "Upload failed: " . $_FILES['file']['error'] . "<br>";
}
if($Notify) echo "<script language=\"javascript\">alert(\"Upload complete.\");</script>";
}
}
else
{

echo "Max filesize is " . $MAX_FILE_SIZE . " bytes.<br>\n";

?>

<form name="ul" enctype="multipart/form-data" action="upload.php" method="POST">
File: <input type="file" name="file"><br>
Path: <input type="text" name="path">
<?php
echo "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"" . $MAX_FILE_SIZE . "\">";
?><br>
<input type="checkbox" name="notify"> Show popup message when finished (requires Javascript)<br>
<input type="submit" value="Upload">
</form>
<?php } ?>


Interestingly enough, when the upload fails, it says the file is 0 bytes.
Narf
Posts: 91/100
Post the script you're using.
HyperLamer
Posts: 7704/8210
Possibly, but I would need to split them manually, which isn't really going to work so well.
Ragnara
Posts: 25/28
You could also upload your files in small chunks and then have a php script copy these parts into a single file, couldn't you?
HyperLamer
Posts: 7669/8210
Thanks! I didn't think scripts would be allowed to override the settings. Is there a way to set the size to unlimited? This script is only for administrative (read: my) use anyway, so there's no need for a limit.

[edit] 6MB uploads still fail with upload_max_filesize at 50MB and max_input_time at 300 seconds. (And it didn't appear to take 5 minutes.) post_max_size is already 55MB. No errors show up, it just doesn't upload and move_uploaded_file() fails.
sloat
Posts: 85/85
check out ini_set()
HyperLamer
Posts: 7656/8210
Yeah, I figured that would be it. Not really a good option, because the files are like 50MB and don't compress well.

But I got them from elsewhere anyway. And the uploader will come in handy for other things.
Elric
Posts: 652/687
I don't know of a way to bypass it, but then again, I'm still a PHP novice, and I don't know how to make an FTP PHP script to begin with.

However, if you can't find a way to bypass it, and/or the admins won't raise it, the only option I can think of is RAR...

RAR the files you want to upload, and when you make the archive, choose to split it into 1.98MB files. This way, you have a little breathing room before you hit the 2MB limit. With a 50MB file, you'll end up with about 26 parts, which won't be fun, but they'll be there.

Of course, if you're not uploading the files from place A so you can go to place B and download them later, then RAR probably isn't a viable option...
HyperLamer
Posts: 7641/8210
Ah, should have thought of that. As I feared, it's set to the default 2MB. Don't suppose it's possible to bypass? I need to upload a few files up to 50MB each, just once... I'll ask the admins but I doubt they'll do it.
Elric
Posts: 651/687
Originally posted by HyperFapper
I wrote a simple file upload script, nothing too special but it works. The problem is it fails with large files (worked fine with 20K but failed with 6MB). I imagine this is due to the upload_max_filesize in php.ini. Is it possible for me to at least know what this is set to?
There's a magical PHP function called phpinfo(); that tells you all kinds of faptastic info.

Just make a PHP file with that in it, save it as something like info.php, upload it, visit it in your browser, and use CTRL+F to search for upload_max_filesize.
HyperLamer
Posts: 7621/8210
I wrote a simple file upload script, nothing too special but it works. The problem is it fails with large files (worked fine with 20K but failed with 6MB). I imagine this is due to the upload_max_filesize in php.ini. Is it possible for me to at least know what this is set to? I don't think I can change it. Is it possible to 'bypass' by handling the file in chunks or something crazy like that?

Also are there any security issues involved with allowing any file to be uploaded, but tacking random numbers onto its extension? I checked that a file like 'blah.php47567568' is treated as text, not as PHP (and the numbers are 7 digits so it won't ever come out as .php3 or some such ), but I don't know if other types of files will be handled the same way.
Acmlm's Board - I2 Archive - Programming - PHP - Can't upload big files


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.005 seconds.