imagecreatefromjpeg not upload big size file size in php


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.
Geeth JanarthananAsked:
Who is Participating?
Ganesh GuruduSenior ConsultantCommented:
  • Login to the cPanel.
  • File Manager in the cPanelFind the File Manager in File section of the Cpanel. Review our tutorial on using the Code Editor within the File manager if you're looking on information how to use it.
  • File Manager iconsNavigate to the directory where you will either save or edit the PHP.INI file and then select the file and use the Code Editor. To open the file, you can click on it to select the file and then click on the Code Editor icon in the menu bar of the File Manager. You can also right-click with your mouse and select Code Editor from the menu that appears.
  • Edit the section of the PHP.INI that you wish to change.
  • Click on SAVE CHANGES in the top right hand corner in order to save your modifications or additions to the file.

check this URL
Ganesh GuruduSenior ConsultantCommented:

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
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
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.
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Dave BaldwinFixer of ProblemsCommented:
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.
Geeth JanarthananAuthor Commented:
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.
Ganesh GuruduSenior ConsultantCommented:
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.
Geeth JanarthananAuthor Commented:
I can't find php.ini file in my cpanel.that's why am create new file but still got issue.
Geeth JanarthananAuthor Commented:
Thanq so much for response.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.