Forum Moderators: coopster
The first topic deals with PHP resizing large image file uploads (over 1mb.). While it is possible by setting the memory_limit() I am curious how others handle this issue with multiple fields in one form. For example, MY current form has 5 fields, if a user places a 1mb image file in each field, PHP is now faced with resizing 5mb of data (resize photos to a size which will download quickly on a site). Is it possible to loop through the fields, process the 1mb photo, free the used memory and move to the next 1mb file? Maybe this is handled automatically by php?
Another factor to consider is the example of 50+ users all-attempting to upload 5 1mb files simultaneously. Now PHP is processing 250mb worth of data, is this possible or does the memory_limit() kick in?
My second concern is Digital Cameras today and in the future. Many cameras are set by default to take 2mb and higher photos and the majority of users today aren’t even aware of how to change the settings to take smaller photos, let alone crop a photo on their computer before attempting an upload. My concern is that memory_limits() exhausted errors, server time-out issues, etc. will only increase.
Thoughts, opinions, comments, suggestions welcome!
PHP allows you to limit the size of the file upload with an invisible tag in your form.
<input type="hidden" name="MAX_FILE_SIZE" value="10000" />
in php
$errorCode = $_FILES['myFile']['error'];
if the PHP engine finds that the uploaded file's size is larger than the value specified by the MAX_FILE_SIZE form field, it will give the error code UPLOAD_ERR_FORM_SIZE
But better use upload_max_filesize php directive