Pablo Colla
Pablo Colla

Reputation: 217

How to set a different max_file_size other than that of the .ini for a single file uploader script

Let's say I have max_file_size set to 20mb but I want to limit it to 4mb on a particular file only, how would I achieve this?

Upvotes: 1

Views: 1080

Answers (1)

Rezigned
Rezigned

Reputation: 4932

Try this.

$default_max_file_size = ini_get('upload_max_filesize');

if ($is_special_file) {
   ini_set('upload_max_filesize', '4M');

   // process your file

   // set it back to original value
   ini_set('upload_max_filesize', $default_max_file_size);
}

Upvotes: 1

Related Questions