How can I limit the upload format and size?

Source: Internet
Author: User
Tags upload php
After reading the document for a long time, I didn't understand how to limit the upload size and format. Could you please give me some answers? Thank you. It would be better to have a demo. I have been using the form upload php sdk for a long time. I have not understood how to restrict the upload size and format. Could you please give me some answers? Thank you.

It would be better to have a demo.

I used the php sdk for form upload.

Reply content:

After reading the document for a long time, I didn't understand how to limit the upload size and format. Could you please give me some answers? Thank you.

It would be better to have a demo.

I used the php sdk for form upload.

You can set fsizelimit in the policy to limit the size.
FsizeLimit ● specifies the size of the uploaded file. The unit is bytes. If the size of the uploaded content exceeds the limit, the system determines that the upload fails and returns the 413 status code.

You can set detectMime and mimeLimit in the policy.

DetectMime ● enable MimeType Detection
If it is set to a non-zero value, the MimeType information of the file transmitted by the upload end is ignored. The qiniu server uses the content detection result
The default value is 0. If MimeType is specified on the upload end, the value is used directly. Otherwise, the MimeType value is detected in the following order:
1. Check the file extension
2. Check the Key Extension
3. detection content.
MimeLimit ● specify the file type uploaded by the user
Specify the value of this field. The qiniu server detects the file content to determine the MimeType, and then matches the value with the specified value. If the matching succeeds, upload is allowed. If the matching fails, a 403 status code is returned.
● Example
1. "image/*" indicates that only the image type can be uploaded;
2. "image/jpeg; image/png" indicates that only jpg and png images can be uploaded;
3. "! Application/json; text/plain "indicates that uploading of json text and plain text is prohibited (note the exclamation point at the beginning ).

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.