How can I limit the upload format and size

Source: Internet
Author: User
Tags upload php
For a long time the document did not understand how to limit the upload size and upload format, please master can answer thank you.

It would be better if we could have a presentation.

I'm using a form to upload PHP SDK

Reply content:

For a long time the document did not understand how to limit the upload size and upload format, please master can answer thank you.

It would be better if we could have a presentation.

I'm using a form to upload PHP SDK

Limit size can be set in policy fsizelimit
Fsizelimit limit the size of the uploaded file, in bytes (byte) exceeding the limit of upload content will be sentenced to upload failed, return 413 status code.

The limit suffix can be set in policy detectmime,mimelimit

Detectmime turn on the mimetype detection function
Set to a value other than 0, ignores the file mimetype information that is passed on the upload side, and uses the seven KN server to detect the content.
The default value is set to 0, which is used directly if MimeType is specified on the upload side, otherwise the MimeType value is detected in the following order:
1. Check the file name extension
2. Check the key extension
3. Detect content.
Mimelimit limit the types of files that users upload
Specify the value of this field, seven cattle server will detect the contents of the file to determine the mimetype, and then use the judgment value to match the specified value, matching success allows uploading, matching failed to return 403 status code
Example
1. "Image/*" indicates that only the image type is allowed;
2. "Image/jpeg;image/png" means that only images of JPG and PNG types are allowed to be uploaded;
3. "!application/json;text/plain" means to disallow uploading of JSON text and plain text (note the first exclamation point).

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.