0

I have a PHP script that allows users to upload numerous files. Unfortunately, my web hosting provider (1&1) has set a relatively small maximum file size limit in the php.ini file.

Currently, users receive no response when the files submitted exceed the maximum amount allocated to be stored at one time by 1&1. Is there a way in PHP where I can find out if files are rejected due to this matter and then output a response for that?

3
  • you can check file size using $_FILE['file']['size'] and throw appropriate error Commented Sep 14, 2014 at 16:16
  • 1
    FYI, upload_max_filesize is a PHP_INI_PERDIR directive. You can tweak it to your liking. Commented Sep 14, 2014 at 16:17
  • You need to tell the user that the limit is exceeded and they should upload smaller files. You can do this by going through your code, edit and echoing the message correspondingly. If you don't have any coding capability. Look for some one else who is knowledgeable. Commented Sep 14, 2014 at 16:17

2 Answers 2

2

Use the value of $_FILE['file']['error']. The value is 0 if there were no errors and >0 if there were. Error numbers can be found here: http://php.net/manual/en/features.file-upload.errors.php

You would probably get error 1 (UPLOAD_ERR_INI_SIZE).

Sign up to request clarification or add additional context in comments.

Comments

2

File uploading stuff is explained at Features/ Handling file uploads. If you look at Error Messages Explained you'll see you just need to test against UPLOAD_ERR_INI_SIZE.

Most modern browsers nowadays support checking file size before uploading (via client-side JavaScript), you should consider adding that check.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.