I'm designing a simple content management system with PHP, and it is
going great, except...

I do seem to have one problem - I'm trying to use PHP's copy function to
upload files through a web browser.  It works fine on small files, but
times out on large ones, like a 20 MB file I'm sending.  I'm on a 1Mbps
DSL connection, and routinely download 600MB iso images with no problem,
and seem to be having no connection problems on this end.  My client is
also getting timeouts on large files, and they're on a different network.

The web server is running Debian Linux kernel 2.2.19; Apache/1.3.9; PHP
4.0.6 at a web hosting company.

I checked the PHP manual, it said that the default maximum file upload
size is 2MB.  I used phpinfo() to show the server settings, and it reports
that it is:

upload_max_filesize=2M
post_max_size=8M
max_execution_time=30

which is the global file upload maximum and POST maximum and execution
limit.  I changed /cgi-bin/php.ini to include the lines

upload_max_filesize=200M
post_max_size=200M
max_execution_time=2400
memory_limit=120M

and saved it.  I tried my upload again, but it still times out. Does
Apache need to be restarted for the change to take effect?  I ran
phpinfo() again, and it shows

upload_max_filesize=200M
post_max_size=200M
max_execution_time=2400

so it looks like it took the change to php.ini.

I successfully uploaded a 1.8MB file, a 2.2MB file, a 4.1MB file, a 5.4MB
file, a 6.1MB file, a 6.9MB file, and a 7.05MB file, but a 7.248MB file
and a 7.6MB file timed out like the larger one.

I'm doing the upload from IE 6.0 on Windows 2000 (running on my Linux box
with VMware). I got the same results on Mozilla 0.9.6 on Mandrake Linux
8.0.

I've read that PHP file uploads are done in RAM, so perhaps that is part
of the problem?

Unfortunately, my client plans to upload ~90MB files this way, and I'd
like to leave PHP file upload as the only method needed.

Here's part of the page using the upload/rename/delete script.  It works
flawlessly on smaller files.

The only timeout (that I *know of!*) that I don't know how to change is the
Apache timeout of 300 seconds.  It appears that it is indeed timing out
after 300 seconds (five minutes). It shows as HTTP_KEEP_ALIVE = 300 in
phpinfo().

All of this is done on a virtual server at a web host, so I don't have
access to the httpd.conf for Apache, although they *might* change it if I
know what to ask them...  ;-)

TIA

Fred

/* New to Linux (nine months) and PHP (2 weeks) but loving it! */

======================================================================

<TABLE BORDER=0 WIDTH="100%" CELLSPACING=2 CELLPADDING=2 ALIGN=CENTER>

<?php
//print("\$Clientcode = $Clientcode, \$Usercode = $Usercode\n");
/* This file lists all the information for files in a directory and allows the user to 
delete, upload and rename files. 
*/

if ($Upload) { // Handle file uploads.
        print ("<TR><TD COLSPAN=4 ALIGN=CENTER>Uploaded file name: 
$File_name</TD></TR>\n");
        print ("<TR><TD COLSPAN=4 ALIGN=CENTER>Uploaded file size: 
$File_size</TD></TR>\n");
        if (copy ($File, "documents/$Folder/$File_name")) {
                print ("<TR><TD COLSPAN=4 ALIGN=CENTER>Your file, $File_name, was 
successfully uploaded!</TD></TR>\n");
        } else {
                print ("<TR><TD COLSPAN=4 ALIGN=CENTER>Your file, $File_name, could 
not be copied.</TD></TR>\n");
        }
        unlink ($File);
        print ("<TR><TD COLSPAN=4 ALIGN=CENTER>&nbsp;</TD></TR>\n");
}

if ($Delete) { // Handle file deletions.
        for ($i = 0; $i < count ($Delete); $i++) {
                if ( unlink ("documents/$Folder/$Delete[$i]") ) {
                        print ("<TR><TD COLSPAN=4 ALIGN=CENTER>Your file, $Delete[$i], 
was successfully deleted!</TD></TR>\n");
                } else {
                        print ("<TR><TD COLSPAN=4 ALIGN=CENTER>Your file, $Delete[$i], 
could not be deleted.</TD></TR>\n");
                }
        }
        print ("<TR><TD COLSPAN=4 ALIGN=CENTER>&nbsp;</TD></TR>\n");
}

if ($Rename) { // Handle file renaming.
        for ($n = 0; $n < count ($Rename); $n++) {
                $OldFilename = $Rename[$n];
                $Old = "documents/$Folder/$OldFilename";
                $New = "documents/$Folder/$NewName[$OldFilename]";
                if ( rename ($Old, $New) ) {
                        print ("<TR><TD COLSPAN=4 ALIGN=CENTER>Your file, $Rename[$n], 
was successfully renamed!</TD></TR>\n");
                } else {
                        print ("<TR><TD COLSPAN=4 ALIGN=CENTER>Your file, $Rename[$n], 
could not be renamed.</TD></TR>\n");
                }
        }
        print ("<TR><TD COLSPAN=4 ALIGN=CENTER>&nbsp;</TD></TR>\n");
}

// Start the form.
$HTTP_KEEP_ALIVE = "2400";
print ("<FORM METHOD=POST ENCTYPE=\"multipart/form-data\" ACTION=\"files.php\">\n");
print ("<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"200000000\">\n"); // max 
file size set to
200 MB
print ("<TR><TD><h2>Folder <b><i>$Folder</i></b>:</h2></TD></TR>\n");
print ("<TR><TD><B>File Name</B></TD><TD><B>File 
Size</B></TD><TD><B>Delete</B></TD><TD><B>Rename</B> (Enter the New Name in the 
Box)</TD></TR>\n");

// Read the files from the directory.
$Open = opendir ("documents/$Folder");

while ($Files = readdir ($Open)) {
        $Filename = "documents/$Folder/" . $Files;
        if (is_file ($Filename)) {
//              hide "hidden" files that start with "."...
                $filenamefirstchar = substr($Files,0,1);
                if ($filenamefirstchar <> ".") {
                        $Size = filesize ("documents/$Folder/$Files");
                        print ("<TR><TD>$Files</TD><TD>$Size</TD><TD><INPUT 
TYPE=CHECKBOX NAME=\"Delete[]\" VALUE=\"$Files\"></TD><TD><INPUT TYPE=CHECKBOX 
NAME=\"Rename[]\" VALUE=\"$Files\"><INPUT TYPE=TEXT 
NAME=\"NewName[$Files]\"></TD></TR>\n");
                }
        }
}
closedir ($Open);

// Give the upload option.
print ("<TR><TD COLSPAN=4 ALIGN=CENTER>&nbsp;</TD></TR>\n");
print ("<TR><TD COLSPAN=4 ALIGN=CENTER><INPUT TYPE=CHECKBOX NAME=\"Upload\" 
VALUE=\"Yes\">Upload a file to folder <b><i>$Folder</i></b>:<br><INPUT TYPE=FILE 
NAME=\"File\" SIZE=90></TD></TR>\n");

print ("<input type=hidden name=\"Folder\" value=\"$Folder\">\n");
// print ("<input type=hidden name=\"Usercode\" value=\"$Usercode\">\n");
// print ("<input type=hidden name=\"Clientcode\" value=\"$Clientcode\">\n");

print ("<TR><TD COLSPAN=4 ALIGN=CENTER><INPUT TYPE=SUBMIT NAME=\"SUBMIT\" 
VALUE=\"Submit!\">
</FORM></TD></TR>\n");
?>
</TABLE>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to