March 16, 200818 yr So, I have the following code: <? function getImgFileType($type) { if($type=='image/jpeg' or $type=='image/pjpeg' or $type=='image/jpg') $type='jpeg'; elseif($type=='image/gif') $type='gif'; elseif($type=='image/png') $type='png'; else $type=''; return $type; } ?> <? if(isset($_POST['submit'])) { $img='poza'; $name=$_FILES[$img]['tmp_name']; $type=$_FILES[$img]['type']; $type=getImgFileType($type); $func="imagecreatefrom$type"; $image=$func($name); } ?> <br /> <br /> <form enctype="multipart/form-data" action="" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="10485760" /> <input name="poza" type="file" /> <input type="submit" name="submit" value="Send File" /> </form> When I try files larger than 1mb, it gives me the following error: Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 13824 bytes) in /home/mobilado/public_html/admin/t.php on line 21 Why???
March 16, 200818 yr Author P.S. I tried all kind of things like: ini_set('post_max_size',"40M"); ini_set('upload_max_filesize',"40M"); ini_set("memory_limit","40M"); Trying to limit the memory to 40M, didn't work!
March 16, 200818 yr Author I managed to do it, but only if i set the memory_limit higher than 40M, isn't there another solution?
March 16, 200818 yr Author I noticed that, even though I set my memory_limit up to 40M, i can't upload files larger than 2mb. Help somebody?
March 16, 200818 yr Author Yes, I'm on shared hosting. Sorry for not editing my messages, but I wrote them kinda in a rush. Sorry again.
March 16, 200818 yr the server is probably set up not to allow in-script setting changes, and as such the default limit of 2M applies. You will need to search and replace the php.ini for "2M" with "40M" to make it work, and this change will be global.
March 16, 200818 yr Author I don't have access to php.ini How can I find out if I am allowed to do in-script changed? If i set up the memory_limit with ini_set, if later in the script i echo somewhere with ini_get the memory limit, it gives me the value i set
March 16, 200818 yr Author Hohohoh!!! I did it! Just throw this: php_value upload_max_filesize 50M in your .htaccess and it will work! Finally!!!!
Create an account or sign in to comment