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 ).