Reducing filesize locally before upload?

Posted on 2009-02-08
Last Modified: 2013-12-25
Is it possible to reduce a file size of an image BEFORE its uploaded to my server.
My php uploads have a limit of 2mb I could just increase it but I have about 100 uploads of some quite large images a day onto my site and would like to know if its possible to reduce this locally before it uploads?

My alternative would be asking the visitors to keep the size down before uploading, but  some users dont even know what 2mb means. The easier I can make it the better but at the same time I dont want huge files eating at my bandwidth which is what is happening at the moment!

I know there is imagemagick which is what I am currently using to resize and create thumbnails but I want the original file compressed before upload.

Is this possible?
Question by:misi_uk
    LVL 20

    Expert Comment

    Yes, your users can download and install some image manipulating software like GIMP and edit their images (e.g. scale down or reduce jpeg quality) until the size requirements are met.
    LVL 82

    Accepted Solution

    >>Is it possible to reduce a file size of an image BEFORE its uploaded to my server.
    No, YOU can't do this. PHP runs on YOUR server. You don't have access to the user's file system. Your only options are:
    a. ask user to resize their files
    b. increase the upload limit.

    >>I could just increase it but I have about 100 uploads of some quite large images a day onto my site
    OK, but if you want small images to begin with, you an increase the upload limit and resize the images yourself once uploaded.

    Expert Comment

    You can change the 2mb limit by configuring the server "php.ini"

    or if you dont have access to the php.ini in the server you can make these changes in  ".htaccess" file

    php_value post_max_size 16 MB
    php_value upload_max_filesize 16 MB
    php_value max_execution_time 60

    I Hope this help you.

    Expert Comment

    Other solution is that you give those users ftp access....

    Author Comment

    Thanks I did think that but wasnt sure if I was missing something somewhere

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Get error when search query run in loop 3 24
    exchange, scripts 3 34
    Total days in a month 12 27
    Help to run a simple query in PHP 17 24
    Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now