Imark Posted February 6, 2007 Share Posted February 6, 2007 When I use the same code to upload a small file, it works fine. But when I select a big file (19 MB *.wmv video), the upload fails. There are no warnings or errors shown, even though I have the "or die" statement on the move_uploaded_file() and mysql_query() function calls. I tried increasing the "<input type="hidden" name="MAX_FILE_SIZE" value="2000000">" to 2000000000. I changed to "upload_max_filesize = 25M" in the 3 php.ini's that I found. Didn't help. What else can it be? <form method="post" enctype="multipart/form-data"> <table width="350" border="0" cellpadding="1" cellspacing="1" class="box"> <tr> <td>First name: <input name="fname" type="text"><br></td> <td>Last name: <input name="lname" type="text"><br></td> <td width="246"> <input type="hidden" name="MAX_FILE_SIZE" value="2000000"> <input name="userfile" type="file" id="userfile"> </td> <td width="80"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td> </tr> </table> </form> <?php // Insert form values (fname, lname, userfile info) $uploadDir = "C:\\xampp\\xampp\htdocs\upload\\"; if (isset($_POST['upload']) && !empty($_POST['fname']) && !empty($_POST['lname']) && !empty($_FILES['userfile']['name'])) { $fname = $_POST['fname']; $lname = $_POST['lname']; $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath) or die ('File upload failed: ' . mysql_error()) ; if (!$result) { echo "Error uploading file"; exit; } include 'config.php'; include 'opendb.php'; if (!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); $filePath = addslashes($filePath); } $query = "INSERT INTO med_test (fname, lname, fileName, size, type, link, time) VALUES ('$fname', '$lname', '$fileName', '$fileSize', '$fileType', '$filePath', NOW())"; mysql_query($query) or die ('insert query failed: ' . mysql_error()); include 'closedb.php'; echo "<br> Files uploaded<br>"; } else { echo "Must fill in all fields "; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/37380-uploading-a-big-file/ Share on other sites More sharing options...
ultrus Posted February 7, 2007 Share Posted February 7, 2007 I seem to have similar problems which may or may not be related. I'm curious to see the answer as well. Quote Link to comment https://forums.phpfreaks.com/topic/37380-uploading-a-big-file/#findComment-178813 Share on other sites More sharing options...
Imark Posted February 7, 2007 Author Share Posted February 7, 2007 I restarted Apache, but it didn't help either. It's obviously some restriction, and not a problem with the code. ??? Quote Link to comment https://forums.phpfreaks.com/topic/37380-uploading-a-big-file/#findComment-179294 Share on other sites More sharing options...
Balmung-San Posted February 7, 2007 Share Posted February 7, 2007 This is caused by PHP timing out most likely. You'd need to edit the max_execution_time in your php.ini. Quote Link to comment https://forums.phpfreaks.com/topic/37380-uploading-a-big-file/#findComment-179297 Share on other sites More sharing options...
Ninjakreborn Posted February 7, 2007 Share Posted February 7, 2007 The server can time out during the upload. What happens, does it go to a blank screen, or loads forever. A 25mb file would take roughly 30-45 minutes on average for a php script to upload, that take's time. 4 fairly large images each less than a meg, can take 5 minutes depending. If not that then most likely the server time'd out. Quote Link to comment https://forums.phpfreaks.com/topic/37380-uploading-a-big-file/#findComment-179298 Share on other sites More sharing options...
The Little Guy Posted February 7, 2007 Share Posted February 7, 2007 Why are you checking for a mysql error? http://us2.php.net/manual/en/function.set-time-limit.php Quote Link to comment https://forums.phpfreaks.com/topic/37380-uploading-a-big-file/#findComment-179299 Share on other sites More sharing options...
Imark Posted February 8, 2007 Author Share Posted February 8, 2007 This is caused by PHP timing out most likely. You'd need to edit the max_execution_time in your php.ini. The server can time out during the upload. What happens, does it go to a blank screen, or loads forever. A 25mb file would take roughly 30-45 minutes on average for a php script to upload, that take's time. 4 fairly large images each less than a meg, can take 5 minutes depending. If not that then most likely the server time'd out. It gives the form back, without the confirmation message "file uploaded." The file and the server are on my local machine that I'm using to develop. It shouldn't be taking 60 sec to copy an 18 MB file from one directory to another. And it doesn't give a blank screen (like an unending loop). It shows the form right away. Why are you checking for a mysql error? I shouldn't be? :-\ Quote Link to comment https://forums.phpfreaks.com/topic/37380-uploading-a-big-file/#findComment-179645 Share on other sites More sharing options...
redarrow Posted February 8, 2007 Share Posted February 8, 2007 try using the proper form conditions ok <!-- The data encoding type, enctype, MUST be specified as below --> <form enctype="multipart/form-data" action="__URL__" method="POST"> <!-- MAX_FILE_SIZE must precede the file input field --> <input type="hidden" name="MAX_FILE_SIZE" value="30000" /> <!-- Name of input element determines name in $_FILES array --> Send this file: <input name="userfile" type="file" /> <input type="submit" value="Send File" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/37380-uploading-a-big-file/#findComment-179676 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.