Forum Moderators: coopster

Message Too Old, No Replies

file upload in php

file upload fails in php

         

kirku

10:09 am on Jul 9, 2009 (gmt 0)

10+ Year Member



Hai,

In my site ,I have to upload files .I can upload files having small size.But now I want to upload files having size up to 50-80 MB.

I am using php5

I changed the php5.ini file as

memory_limit = 300M
upload_max_filesize = 200M
post_max_size = 500M
max_execution_time = 4000

It fails after some time.Error shows as 'Connection Interupted'.

In the specific page (upload.php) also I changed the code as

set_time_limit(0);
ini_set("memory_limit","300M");
ini_set("upload_max_filesize","300M");
ini_set("post_max_size","300M");
ini_set("max_execution_time",3000);

Still the process fails....

Can any one help me...

Thanks&Regards
Kiran

abidshahzad4u

1:51 pm on Jul 9, 2009 (gmt 0)

10+ Year Member



Use PHP HTTP Streaming. For more use Google.

rocknbil

4:32 pm on Jul 9, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard kirku, just FYI, you can also set this in an .htaccess in the directory where they are performed rather than the system-wide .ini. That way it limits the possibility of abuse in other areas of your site.

With files of this size it's going to be impossible to determine a "safe" max_execution_time because your users, and even you, will experience time differences in upload as the transfer speed comes and goes.

A possible solution might be to fork() your process. A fork spawns a child process, identified by process id ($pid in example) that runs in the background, something like

if ($pid=fork()) {
// this is the parent process, return "job uploading" to browser immediately
}
else {
// perform time consuming task of upload in this child process
}

You'd have to construct some mechanism to "check" whether the process is "done" and report back to the browser. Once scenario would be in your parent process have a 5 second meta-refresh that calls a function to check if the process $pid is running, if it no longer exists the upload in the child process is complete.