westman Posted November 22, 2012 Share Posted November 22, 2012 hi there,i have made lots of working upload scripts and this if from 1 of them that i am having problems with... if ($_FILES['video_upload']['tmp_name'] != "") {$maxfilesize_vid = 203554432;if($_FILES['video_upload']['size'] > $maxfilesize_vid ) { $errorMsg_upload = "Your Video was too large. Must be 22MB or less, please try again."; unlink($_FILES['video_upload']['tmp_name']); here in $maxfilesize_vid i set it to 203554432 is that 22MB?plus i am aware that servers can have upload limits, so i spoke with my server admin and they told me to use... memory_limit = 50Mpost_max_size = 15Mfile_uploads = Onupload_max_filesize = 25M in file name php.ini to get the max file upload to 25MB i am still having problems when i try to upload a file that is 15MB but no problem from a file 3MB large.any help? Link to comment Share on other sites More sharing options...
phpnoob Posted November 22, 2012 Share Posted November 22, 2012 (edited) not sure but maybe the problem is here if($_FILES['video_upload']['size'] <= $maxfilesize_vid ) { the > was the problem Edited November 22, 2012 by phpnoob Link to comment Share on other sites More sharing options...
westman Posted November 22, 2012 Author Share Posted November 22, 2012 i have always used... if($_FILES['video_upload']['size'] > $maxfilesize_vid ) {and it has worked fin and this problem i have, that i still have not fond do not give error messages Link to comment Share on other sites More sharing options...
JamesB Posted November 22, 2012 Share Posted November 22, 2012 (edited) post_max_size should be more than upload_max_filesize, as the post data is the entire file(s) + extra datahttp://uk3.php.net/m...i.post-max-sizehttp://uk3.php.net/m...ad-max-filesize Edited November 22, 2012 by JamesB Link to comment Share on other sites More sharing options...
westman Posted November 22, 2012 Author Share Posted November 22, 2012 my php.ini file now looks like this... register_globals = offallow_url_fopen = off expose_php = Offmax_input_time = 60variables_order = "EGPCS"extension_dir = ./upload_tmp_dir = /tmpprecision = 12SMTP = relay-hosting.secureserver.neturl_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset=" memory_limit = 50Mpost_max_size = 200Mfile_uploads = Onupload_max_filesize = 100M when i upload a file that is 10MB it uploads as normal and at 100% uploaded the page refresh's and nothing happens with no positive or negative errors.any help? Link to comment Share on other sites More sharing options...
justsomeguy Posted November 26, 2012 Share Posted November 26, 2012 here in $maxfilesize_vid i set it to 203554432 is that 22MB?No, it's 194MB. 22MB is 23068672 bytes. If you upload a file that is too large though then PHP will indicate that in the error property of the $_FILES array. Other than that, you didn't post enough code to try and guess what is happening or what is supposed to happen. Link to comment Share on other sites More sharing options...
westman Posted December 3, 2012 Author Share Posted December 3, 2012 sorry for late response my pc broke, am back now i tried 23068672 bytes for 22 MB and i uploaded a file 18 MB with no problem thank you for them numbers last one, could i have the numbers that equal 100 MB so i can upload any file under 100 MB please Link to comment Share on other sites More sharing options...
justsomeguy Posted December 3, 2012 Share Posted December 3, 2012 1 MB is 2^20. You can multiply that by whatever you want to get the number of bytes. Link to comment Share on other sites More sharing options...
westman Posted December 3, 2012 Author Share Posted December 3, 2012 is 104857600 bytes 100 MB? Link to comment Share on other sites More sharing options...
justsomeguy Posted December 3, 2012 Share Posted December 3, 2012 Right. For reference, 1 KB is 2^10, 1 MB is 2^20, 1 GB is 2^30, 1 TB is 2^40, etc. Link to comment Share on other sites More sharing options...
Don E Posted December 3, 2012 Share Posted December 3, 2012 When it comes to the above, I use this site: http://www.unitconversion.org/unit_converter/data-storage.html Very useful. Link to comment Share on other sites More sharing options...
westman Posted December 3, 2012 Author Share Posted December 3, 2012 ok i trid to upload a file that was 47MB in size and my limit was set to 100MB and it did not work :(could it be the time it took to upload like a time out? Link to comment Share on other sites More sharing options...
justsomeguy Posted December 3, 2012 Share Posted December 3, 2012 It could be the time but I've never run into that with uploads, even with files of several hundred MB. I don't think the timer starts running until the upload and request finishes. Link to comment Share on other sites More sharing options...
westman Posted December 3, 2012 Author Share Posted December 3, 2012 so what could it be? this is my full upload script... if ($_FILES['video_upload']['tmp_name'] != "") {$maxfilesize_vid = 104857600;if($_FILES['video_upload']['size'] > $maxfilesize_vid ) { $errorMsg_upload = "Your Video was too large. Must be 22MB or less, please try again."; unlink($_FILES['video_upload']['tmp_name']);}else if (!preg_match("/\.(avi|mp4|wmv|mov|flv|swf)$/i", $_FILES['video_upload']['name'] ) ) { $errorMsg_upload = "Your Video was not .avi, .mp4, .wmv, .mov, .flv or .swf and it must be one of those 6 formats, please try again"; unlink($_FILES['video_upload']['tmp_name']);} else {$find_fileinfo_video = mysql_query("SELECT * FROM vid ORDER BY id DESC LIMIT 1") or die (mysql_error());$find_fileinfo_video_check = mysql_num_rows($find_fileinfo_video);if ($find_fileinfo_video_check == 0){$vid_file_id = "1";}else{while ($row = mysql_fetch_array($find_fileinfo_video)) {$vid_file_id = $row["id"];}$vid_file_id++;}mkdir("vid/$vid_file_id", 0755);$newname1 = "myvid.mp4";if (move_uploaded_file($_FILES['video_upload']['tmp_name'], "video/$vid_file_id/".$newname1)) { $video_image_y_n = "0";if ($_FILES['video_image']['tmp_name'] != "") {$maxfilesize = 43554432;if($_FILES['video_image']['size'] > $maxfilesize ) { $errorMsg_upload = "Your Video image was too large. Must be 4MB or less, please try again."; unlink($_FILES['video_image']['tmp_name']);}else if (!preg_match("/\.(gif|png|jpg|jpeg)$/i", $_FILES['video_image']['name'] ) ) { $errorMsg_upload = "Your Video image was not .gif, .png or .jpg and it must be one of those 3 formats, please try again"; unlink($_FILES['video_image']['tmp_name']);} else {$newname7 = "myvid.gif";if (move_uploaded_file($_FILES['video_image']['tmp_name'], "video/$vid_file_id/".$newname7)) { $video_image_y_n = "1";} else {$video_image_y_n = "0";}}}////// DB info input here $updateMsg_upload = "You successfully uploaded a Video.";} else {$errorMsg_upload = "There was an error uploading your video, please try again. If it continually fails, please contact us.";}}} Link to comment Share on other sites More sharing options...
justsomeguy Posted December 3, 2012 Share Posted December 3, 2012 You need to specify what "did not work" means. What happens when you run it? I notice you're not checking $_FILES['video_upload']['error'] for an error code, you should add that. http://php.net/manual/en/features.file-upload.errors.php Link to comment Share on other sites More sharing options...
westman Posted December 4, 2012 Author Share Posted December 4, 2012 i tried using .... class UploadException extends Exception { public function __construct($code) { $message = $this->codeToMessage($code); parent::__construct($message, $code); } private function codeToMessage($code) { switch ($code) { case UPLOAD_ERR_INI_SIZE: $message = "The uploaded file exceeds the upload_max_filesize directive in php.ini"; break; case UPLOAD_ERR_FORM_SIZE: $message = "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"; break; case UPLOAD_ERR_PARTIAL: $message = "The uploaded file was only partially uploaded"; break; case UPLOAD_ERR_NO_FILE: $message = "No file was uploaded"; break; case UPLOAD_ERR_NO_TMP_DIR: $message = "Missing a temporary folder"; break; case UPLOAD_ERR_CANT_WRITE: $message = "Failed to write file to disk"; break; case UPLOAD_ERR_EXTENSION: $message = "File upload stopped by extension"; break; default: $message = "Unknown upload error"; break; } return $message; }} // Use if ($_FILES['file']['error'] === UPLOAD_ERR_OK) { //uploading successfully done } else { throw new UploadException($_FILES['file']['error']); } near ////// DB info input herein my script but am still not getting any errors. when i upload a file 47 MB in size it gets to 100% and then nothing happens, looks like a page refresh. Link to comment Share on other sites More sharing options...
birbal Posted December 4, 2012 Share Posted December 4, 2012 What do you expect to happen instead? does your file is being saved in server? did you check the filesystem? i cant see anything which can output. you also like to use debug statements to ensure what is happening. Link to comment Share on other sites More sharing options...
westman Posted December 4, 2012 Author Share Posted December 4, 2012 they do not upload to my server. can anyone see why my files are not uploading? Link to comment Share on other sites More sharing options...
birbal Posted December 4, 2012 Share Posted December 4, 2012 check what move_upload_file() is returning. add some debug statements. if $_FILES['file']['error'] is not showing any error that means it is getting uploaded to server but not geting saved. Link to comment Share on other sites More sharing options...
westman Posted December 4, 2012 Author Share Posted December 4, 2012 ok then if a small file gets saved to the server why is a large file not getting saved? Link to comment Share on other sites More sharing options...
justsomeguy Posted December 4, 2012 Share Posted December 4, 2012 That's what you need to figure out. Check if $_POST and $_FILES are empty after you submit the form. If they are both empty then post_max_size was exceeded. Link to comment Share on other sites More sharing options...
westman Posted December 4, 2012 Author Share Posted December 4, 2012 how do i Check if $_POST and $_FILES are empty after you submit the form? Link to comment Share on other sites More sharing options...
justsomeguy Posted December 4, 2012 Share Posted December 4, 2012 You can use count to check the length, use print_r to output the entire thing, loop through it and see what's there, etc. Link to comment Share on other sites More sharing options...
westman Posted December 4, 2012 Author Share Posted December 4, 2012 please can you give me a script example of this that i can use please Link to comment Share on other sites More sharing options...
justsomeguy Posted December 4, 2012 Share Posted December 4, 2012 There are examples in the manual. http://www.php.net/manual/en/function.print-r.phphttp://www.php.net/manual/en/function.count.php Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now