View Full Version : php uploading huge (1GB+) files?
forcemorph
May 24th, 2007, 09:27 AM
Hey all, I need some really technical info I can't seem to find anywhere. I'm trying to make a script that will upload files up to 4 or 5 GB through PHP (it's over local intranet). So far I've gotten it to go up to 1GB by adjusting all of the max size info in php.ini. It literally stops allowing uploads at files over 1GB exactly. The test server I'm using (and all my servers) only have 1GB of RAM. Could this be a physical limitation of PHP? I know PHP handles files in one big POST data chunk, so could memory be filling up and stopping the upload? (I made sure the memory_size php.ini limit was huge.)
Any ideas?
Voetsjoeba
May 24th, 2007, 09:33 AM
The maximum filesize you can upload with PHP is indeed limited by the amount of memory the machine has (and also by upload_max_filesize and post_max_size, but I suppose you've already taken care of those). What happens when you upload a file is that it will be added to the POST data section in the HTTP header you send along in binary format. That POST data is then passed onto the PHP executable by the web server. If PHP has to handle writing a 1GB file, then it will require 1GB of memory for loading it in and actually writing it.
But why on earth do you want to upload such large files through HTTP ? That makes no sense. Use FTP for this.
forcemorph
May 24th, 2007, 09:57 AM
The maximum filesize you can upload with PHP is indeed limited by the amount of memory the machine has (and also by upload_max_filesize and post_max_size, but I suppose you've already taken care of those). What happens when you upload a file is that it will be added to the POST data section in the HTTP header you send along in binary format. That POST data is then passed onto the PHP executable by the web server. If PHP has to handle writing a 1GB file, then it will require 1GB of memory for loading it in and actually writing it.
But why on earth do you want to upload such large files through HTTP ? That makes no sense. Use FTP for this.
It's a web application for end-users, most of which won't want to be bothered with opening up an FTP client. We were thinking of using the built-in PHP FTP classes, but we're trying to run an extremely secure environment and we're not sure how big a security risk it is to have PHP opening sockets.
foodpk
May 24th, 2007, 08:22 PM
Uploading 1 gig worth of data via HTTP is not worth the hassle. It would really work only under very ideal conditions I presume. Also, there's almost no way to provide upload resuming and such via HTTP.
ironikart
May 25th, 2007, 11:17 PM
Also, if you're uploading a 1 gig file via http someone is taking that http child process for the time it takes to upload which = server memory. Get a few people doing this at once and you bring the server down.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.