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 | |
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
User Post
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 7621/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 10-12-05 10:28 AM Link | Quote
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.
Elric

Chasupa


Currently Playing:
You Like A Lute.
Level: 40

Posts: 651/687
EXP: 440016
For next: 1293

Since: 03-15-04
From: Melniboné

Since last post: 6 hours
Last activity: 6 hours
Posted on 10-12-05 10:42 AM Link | Quote
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
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 7641/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 10-13-05 06:01 AM Link | Quote
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.


(edited by HyperFapper on 10-12-05 09:01 PM)
Elric

Chasupa


Currently Playing:
You Like A Lute.
Level: 40

Posts: 652/687
EXP: 440016
For next: 1293

Since: 03-15-04
From: Melniboné

Since last post: 6 hours
Last activity: 6 hours
Posted on 10-13-05 12:29 PM Link | Quote
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
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 7656/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 10-13-05 04:59 PM Link | Quote
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.
sloat

Level: 16

Posts: 85/85
EXP: 18044
For next: 2212

Since: 05-21-04
From: South Central Delaware

Since last post: 19 days
Last activity: 5 hours
Posted on 10-14-05 01:23 AM Link | Quote
check out ini_set()
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 7669/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 10-14-05 05:23 AM Link | Quote
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.


(edited by HyperHacker on 10-13-05 08:26 PM)
Ragnara

Octorok
Level: 7

Posts: 25/28
EXP: 1265
For next: 183

Since: 08-21-05
From: Germany

Since last post: 17 days
Last activity: 13 hours
Posted on 10-14-05 09:44 PM Link | Quote
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
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 7704/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 10-14-05 10:23 PM Link | Quote
Possibly, but I would need to split them manually, which isn't really going to work so well.
Narf
Hi Tuvai!
(reregistering while banned)
Level: 16

Posts: 91/100
EXP: 17634
For next: 2622

Since: 12-26-04

Since last post: 22 hours
Last activity: 14 hours
Posted on 10-15-05 01:58 AM Link | Quote
Post the script you're using.
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 7713/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 10-15-05 02:10 AM Link | Quote
<?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
Hi Tuvai!
(reregistering while banned)
Level: 16

Posts: 92/100
EXP: 17634
For next: 2622

Since: 12-26-04

Since last post: 22 hours
Last activity: 14 hours
Posted on 10-17-05 11:15 PM Link | Quote
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
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 7791/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 10-18-05 12:44 AM Link | Quote
Er... what exactly does that do differently than mine?
Boom.dk

Level: 31

Posts: 388/392
EXP: 168692
For next: 16671

Since: 07-18-04
From: Denmark

Since last post: 10 days
Last activity: 1 day
Posted on 10-18-05 09:46 PM Link | Quote
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


(edited by Boom.dk on 10-18-05 12:46 PM)
Narf
Hi Tuvai!
(reregistering while banned)
Level: 16

Posts: 93/100
EXP: 17634
For next: 2622

Since: 12-26-04

Since last post: 22 hours
Last activity: 14 hours
Posted on 10-21-05 03:06 AM Link | Quote
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

Level: 31

Posts: 392/392
EXP: 168692
For next: 16671

Since: 07-18-04
From: Denmark

Since last post: 10 days
Last activity: 1 day
Posted on 10-22-05 07:53 PM Link | Quote
To me, nothing looks unneccesary in HH's script. It all has its use.
mekakame

Micro-Goomba
Level: 7

Posts: 17/18
EXP: 925
For next: 523

Since: 06-08-05
From: Samut Prakan, Thailand, Asia, Earth, Milky Way, Space...

Since last post: 5 days
Last activity: 1 day
Posted on 10-26-05 06:50 PM Link | Quote
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
HyperLamer
<||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people

Sesshomaru
Tamaranian

Level: 118

Posts: 8007/8210
EXP: 18171887
For next: 211027

Since: 03-15-04
From: Canada, w00t!
LOL FAD

Since last post: 2 hours
Last activity: 2 hours
Posted on 10-26-05 09:21 PM Link | Quote
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

Micro-Goomba
Level: 7

Posts: 18/18
EXP: 925
For next: 523

Since: 06-08-05
From: Samut Prakan, Thailand, Asia, Earth, Milky Way, Space...

Since last post: 5 days
Last activity: 1 day
Posted on 10-28-05 04:38 AM Link | Quote
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.
Add to favorites | "RSS" Feed | Next newer thread | Next older thread
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.012 seconds.