ksmatthews Posted April 3, 2008 Share Posted April 3, 2008 Hi Gurus, I am using php to upload files from a web browser to a linux server. Small files less than about 1Mb are no problem but larger ones cannot get uploaded. In fact 20Mb files will cause the web browser to hang. I have set the php.ini file as follows ... upload_max_filesize 100M 100M This makes no difference !! Has anyone got any ideas ?? Here is the function that I am using .... <?php function uploadfile($message, $path, $file_type, $file_size, $file_content) { // set error flag $file_flag = false; // check for spaces in filename if(strpos($_FILES["moh_file"]["name"], ' ') == true) { $message = 'Error: file name should not contain spaces'; return $file_flag; } // echo $path; die(); // set passed variables $file_type = $_FILES["moh_file"]["type"]; $file_size = $_FILES["moh_file"]["size"]; // check for content if($_FILES['moh_file']['size'] == 0) { $message = 'Error: file has no content (no upload)'; return $file_flag; } // check for size if($_FILES["moh_file"]["size"] > $_POST['MAX_FILE_SIZE']) { $message = 'Error: file is too large (no upload)'; return $file_flag; } // check audio file type if ($_FILES["moh_file"]["type"] == "audio/wav" || $_FILES["moh_file"]["type"] == "audio/wave" || $_FILES["moh_file"]["type"] == "audio/x-wav" || $_FILES["moh_file"]["type"] == "audio/mpeg" || $_FILES["moh_file"]["type"] == "audio/mp3" || $_FILES["moh_file"]["type"] == "audio/x-mpeg" || $_FILES["moh_file"]["type"] == "audio/gsm" || $_FILES["moh_file"]["type"] == "audio/x-gsm" || $_FILES["moh_file"]["type"] == "application/ogg") { if ($_FILES["moh_file"]["error"] > 0) { $message = 'Error: invalid upload (error code: ' . $_FILES["moh_file"]["error"] . ')'; return $file_flag; } else { if (file_exists($path . $_FILES["moh_file"]["name"])) { $message = 'Error: file ' . $_FILES["moh_file"]["name"] . ' already exists.' ; return $file_flag; } else { if(move_uploaded_file($_FILES["moh_file"]["tmp_name"], $path . $_FILES["moh_file"]["name"]) == false) { $message = "Error: file not uploaded to : " . $path . $_FILES["moh_file"]["name"]; return $file_flag; } else { $message = "File uploaded to : " . $path . $_FILES["moh_file"]["name"]; $file_flag = true; } } } // end of first else } else { $message = "Error: invalid file format (no upload)"; return $file_flag; } return $file_flag; } regards, Steven M Quote Link to comment https://forums.phpfreaks.com/topic/99380-solved-uploading-large-files/ Share on other sites More sharing options...
Daniel0 Posted April 3, 2008 Share Posted April 3, 2008 The reason is probably that it's waiting while you're uploading. Depending on your speed, uploading a 20 MB file might take a while. Quote Link to comment https://forums.phpfreaks.com/topic/99380-solved-uploading-large-files/#findComment-508525 Share on other sites More sharing options...
atomicrabbit Posted April 3, 2008 Share Posted April 3, 2008 you should look into using some sort of cgi upload. It can handle larger file sizes better than php. I've had a lot of success with XUpload. It comes with a progress bar too so you know what's happening. Quote Link to comment https://forums.phpfreaks.com/topic/99380-solved-uploading-large-files/#findComment-508533 Share on other sites More sharing options...
Stooney Posted April 3, 2008 Share Posted April 3, 2008 There's actually 4 values you need to change in php.ini upload_max_filesize= 20 M max_execution_time= 1800 memory_limit= 21 M post_max_size= 20 M Also if you're on shared hosting you're probably restricted to 20M max. Quote Link to comment https://forums.phpfreaks.com/topic/99380-solved-uploading-large-files/#findComment-508539 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.