spenceddd Posted February 4, 2010 Share Posted February 4, 2010 Hi I have a bearbones code for uploading files onto my webspace. It seems to work ok on small files but not bigger ones. The range of working file sizes doesn't consistent. I am a real novice with php but here is my code so far: $name = $_FILES["myfile"]["name"]; $type = $_FILES["myfile"]["type"]; $size = $_FILES["myfile"]["size"]; $temp = $_FILES["myfile"]["tmp_name"]; $error = $_FILES["myfile"]["error"]; if (!empty($_POST['uploadDownload'])){ if ($error >0) { die("Error uploading file! Code $error."); }else{ if ($type == "application/x-zip-compressed") { move_uploaded_file($temp, $ddir.$name); print_r($type); //load simpleForm.php page using javascript echo ("<script> <!-- location.replace(\"simpleForm.php\"); --> </script>"); }else{ echo "Wrong file type"; } } and here is the html code: <form enctype="multipart/form-data" action="logosProcessor.php" method="POST"> <p> <input name="newLogoName" type="text" size="25" value="<?php echo $_POST['logoListDropDown']; ?>"> <input type='submit' name="updateLogoName" value="Update Logo Name"/> <input type='submit' name="deleteLogo" value="Delete Logo"/> <input type="hidden" name="oldLogoName" size="25" value="<?php echo $_POST['logoListDropDown']; ?>"> </p> <p> <input type="file" name="myfile"> <input name="uploadLogo" type='submit' value="upload" > </p> </form> I have tried to create a php.ini file in same directory that the rest of my php files for this webapp but that was just a guess and I don't really know what I'm doing. The php.ini file looks like this in totallity: #!/bin/sh upload_max_filesize = 50M post_max_size = 100M Any help would be very gratefully received! Spencer Quote Link to comment https://forums.phpfreaks.com/topic/190931-only-small-files-seem-to-upload-ok/ Share on other sites More sharing options...
$Three3 Posted February 4, 2010 Share Posted February 4, 2010 Have you tried adding the MAX_FILE_SIZE option in the HTML part of your code? If not, then you could try this: <input type="hidden" name="MAX_FILE_SIZE" value="512000" /> The MAX_FILE_SIZE value is the maxium number of bytes you want to be allowed while uploading a file. So 512,000 bytes is 500KB. So if you wanted it to be equal to 50MB you would need to change that value to 52428800. So you whole html code should look like this: <form enctype="multipart/form-data" action="logosProcessor.php" method="POST"> <p> <input type="hidden" name="MAX_FILE_SIZE" value="52428800" /> <input name="newLogoName" type="text" size="25" value="<?php echo $_POST['logoListDropDown']; ?>"> <input type='submit' name="updateLogoName" value="Update Logo Name"/> <input type='submit' name="deleteLogo" value="Delete Logo"/> <input type="hidden" name="oldLogoName" size="25" value="<?php echo $_POST['logoListDropDown']; ?>"> </p> <p> <input type="file" name="myfile"> <input name="uploadLogo" type='submit' value="upload" > </p> </form> Quote Link to comment https://forums.phpfreaks.com/topic/190931-only-small-files-seem-to-upload-ok/#findComment-1006851 Share on other sites More sharing options...
spenceddd Posted February 4, 2010 Author Share Posted February 4, 2010 Ok great thanks! Ill give it a try and let you know. Quote Link to comment https://forums.phpfreaks.com/topic/190931-only-small-files-seem-to-upload-ok/#findComment-1006854 Share on other sites More sharing options...
spenceddd Posted February 4, 2010 Author Share Posted February 4, 2010 That didn't seem to make any difference. The error I get is code 1 which is the error code for max upload size exceeded... Quote Link to comment https://forums.phpfreaks.com/topic/190931-only-small-files-seem-to-upload-ok/#findComment-1006861 Share on other sites More sharing options...
$Three3 Posted February 4, 2010 Share Posted February 4, 2010 That didn't seem to make any difference. The error I get is code 1 which is the error code for max upload size exceeded... How big is the file you are trying to upload? Also, did you edit the original php.ini file on your server of make a new one? Quote Link to comment https://forums.phpfreaks.com/topic/190931-only-small-files-seem-to-upload-ok/#findComment-1006865 Share on other sites More sharing options...
PFMaBiSmAd Posted February 4, 2010 Share Posted February 4, 2010 Adding the MAX_FILE_SIZE field to the form would only serve to limit the maximum size (it would generate an error value of 2) and has nothing to do with getting an error value of 1. Are you sure a local php.ini can be used to change those two settings on your server? What does a phpinfo() statement show for the upload_max_filesize setting? What exact size is the file that is not uploading? Quote Link to comment https://forums.phpfreaks.com/topic/190931-only-small-files-seem-to-upload-ok/#findComment-1006866 Share on other sites More sharing options...
spenceddd Posted February 4, 2010 Author Share Posted February 4, 2010 I haven't been able to update any other php.ini file on the server as I don't know where to look. When I run phpinfo() it says the Loaded Configuration File is: /home/spence13/public_html/portfolioAppFiles/php.ini But above it says: Configuration File (php.ini) Path is: /usr/lib The upload_max_filesize is 5M. Does this also need to be changed? Do I need to worry about max_execution_time being only 30? Is that a timeout or something? Thanks a lot. Spencer Quote Link to comment https://forums.phpfreaks.com/topic/190931-only-small-files-seem-to-upload-ok/#findComment-1006870 Share on other sites More sharing options...
spenceddd Posted February 4, 2010 Author Share Posted February 4, 2010 It seems like I cannot navigate to where the other php.ini is. I guess I will have to ask my hosting company to change the required values. Do you know if the local php.ini would over-ride the settings in the main one (that I cannot directly edit)? If they do maybe I haven't written the code for the local php.ini properly. Literally all thee is in it is: [code=php:0] ; Whether to allow HTTP file uploads. file_uploads = On ; Maximum amount of memory a script may consume (8MB) memory_limit = 8M ; Maximum size of POST data that PHP will accept. post_max_size = 8M ; Maximum allowed size for uploaded files. upload_max_filesize = 2M Quote Link to comment https://forums.phpfreaks.com/topic/190931-only-small-files-seem-to-upload-ok/#findComment-1006880 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.