Link to home
Start Free TrialLog in
Avatar of Geeth Janarthanan
Geeth Janarthanan

asked on

imagecreatefromjpeg not upload big size file size in php

Hi,

Am resize image using resize class in php,

Am attached my resize coding file.

Once am upload small file size it's working fine but larger size not working got error like

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 22504 bytes) in /xxxx/ResizeImage.php on line 54

In line 54 have code like imagecreatefromjpeg.

Php.ini time like don't know still why it's not accept large file size 1.8mb.

max_execution_time      90      90
max_file_uploads      20      20
max_input_nesting_level      64      64
max_input_time      -1      -1
max_input_vars      1000      1000
memory_limit      128M      128M
upload_max_filesize      40M      
post_max_size      20M      20M

PLease give me solution.How to upload 1.5 to 2.5 mb file size to resize.
ResizeImage.php
Avatar of Ganesh Gurudu
Ganesh Gurudu

Hello,

You also need to set cache size parameters.

realpath_cache_size integer
Determines the size of the realpath cache to be used by PHP. This value should be increased on systems where PHP opens many files, to reflect the quantity of the file operations performed.

The size represents the total number of bytes in the path strings stored, plus the size of the data associated with the cache entry. This means that in order to store longer paths in the cache, the cache size must be larger. This value does not directly control the number of distinct paths that can be cached.

The size required for the cache entry data is system dependent.

realpath_cache_ttl integer
Duration of time (in seconds) for which to cache realpath information for a given file or directory. For systems with rarely changing files, consider increasing the value.

can also refer the below URLs
http://sg2.php.net/manual/en/ini.core.php#ini.realpath-cache-size

www.php.net/realpath_cache_ttl
Avatar of David Favor
Looks like memory_limit is the problem. The message about memory size of 134217728 relates to your memory_limit setting, which looks to be the low default.

For my hosting clients I normally change this from the default of 128M to 2G.

I also change a few other options, which you might change also.

In php.ini...

max_input_vars = 10000
memory_limit = 2G 
post_max_size = 256M
upload_max_filesize = 1G

Open in new window


Be sure to bounce (stop/restart or reload) either Apache (if you're running mod_php) or FPM, to ingest these new values.
Also, JPG images have to be decompressed to their raw data and size.  As an example, one JPG I have that is 48K as a file became 1.7MB when I opened it in an image program.  And the image routines frequently require 3 copies of the raw image in memory at once as they process it.  So in my example, a 48K file requires 5.1MB of memory.  Using PHP, that would be in addition to the memory required to run PHP.
Avatar of Geeth Janarthanan

ASKER

Thanx for your reply's But i can't find php.ini file inside my cpanel linux server.Am tried to create php.ini file and paste below code like,

max_input_vars = 10000
memory_limit = 2G
post_max_size = 256M
upload_max_filesize = 1G
realpath_cache_size = 64k
realpath_cache_ttl = 3600

But nothing happend and also same file rename name like .user.ini please help me.
Hello  Janarthanan,

where did you changed this parameters?
you should change in php.ini file.

Not sure, But this should have work now.
just refer the below URL also.
https://www.groovypost.com/howto/howto/how-to-solve-php-fatal-error-allowed-memory-size-of-8388608-bytes-exhausted/
I can't find php.ini file in my cpanel.that's why am create new file but still got issue.
ASKER CERTIFIED SOLUTION
Avatar of Ganesh Gurudu
Ganesh Gurudu

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanq so much for response.