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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
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.
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

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.
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Geeth JanarthananAuthor Commented:
Thanq so much for response.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.