misterx
08-09-2006, 02:43 PM
I've made a PHP script for uploading files to the web server. The script itself seems to work fine but it causes FireFox to warn me about how long the script is taking.
When I tested uploading a 1.6 meg file I had to click the 'Continue' button on the script warning about 7 times. I know that I can change the config in FireFox to increase the script warning time limit but I'm wondering if there's something I can do on the PHP side of things to keep it from doing that. The current code is really simple, I've posted it's pieces below.
$FileName = $_FILES['file']['name'];
$fileSource = $_FILES['file']['tmp_name'];
// Make the dir if it isn't already there
if( $FileName ) {
if( !file_exists(FILE_DIR.$FormID) ) {
mkdir( FILE_DIR.$FormID );
}
}
// Move the file to the right place
$destination = FILE_DIR.$FormID."/".$FileName;
if( $fileSuccess = move_uploaded_file( $fileSource, $destination ) ) {
// Update the database upon success of moving the file
$fileString = "INSERT INTO qaFiles VALUES( null, $FormID, '$FileName' )";
mysql_query( $fileString );
}
Hmm, some of that code is irrelevant but you get the idea. In fact, I don't think it's the code that's causing FireFox to freak out at all. It would have to be the part right before this code is executed when the file is actually being uploaded. Still, I'm open to any ideas.
When I tested uploading a 1.6 meg file I had to click the 'Continue' button on the script warning about 7 times. I know that I can change the config in FireFox to increase the script warning time limit but I'm wondering if there's something I can do on the PHP side of things to keep it from doing that. The current code is really simple, I've posted it's pieces below.
$FileName = $_FILES['file']['name'];
$fileSource = $_FILES['file']['tmp_name'];
// Make the dir if it isn't already there
if( $FileName ) {
if( !file_exists(FILE_DIR.$FormID) ) {
mkdir( FILE_DIR.$FormID );
}
}
// Move the file to the right place
$destination = FILE_DIR.$FormID."/".$FileName;
if( $fileSuccess = move_uploaded_file( $fileSource, $destination ) ) {
// Update the database upon success of moving the file
$fileString = "INSERT INTO qaFiles VALUES( null, $FormID, '$FileName' )";
mysql_query( $fileString );
}
Hmm, some of that code is irrelevant but you get the idea. In fact, I don't think it's the code that's causing FireFox to freak out at all. It would have to be the part right before this code is executed when the file is actually being uploaded. Still, I'm open to any ideas.