When the front-end and background data docking, can not avoid the use of Ajax HTTP request, the common request for two post and get; however, the requirements of the common Post request is file upload, maybe I said that the file upload everyone
We generally do not restrict the user to upload files when the file class, because there is no good way to restrict the use of such as php,asp to operate, I would like to introduce the use of JS to define type=file Browse upload file type and PHP
Is the Upload file type Limited to EXCEL? Use this if ($ _ FILES ['Excel _ file'] ['type']! = 'Application/vnd. ms-excel ') does not seem to work out the EXCEL version. how can this problem be solved? $ imgtype = strtolower (strrchr ($ _ F)
Is the Upload file type Limited to EXCEL? Use this if ($ _ FILES [excel_file] [type]! Applicationvnd. ms-excel) does not seem to be an EXCEL version Problem. how can I solve it? solution -------------------- $ imgtypestrtolower (strrchr ($ _ FILES
The article has two instances is used to detect the upload file type and upload image size, I would like to write separately but feel that two will be better Together, the students need to see.
The code is as follows
Copy Code
Php checks the uploaded file type and image size code. There are two examples in this article to check the Upload file type and the size of the uploaded image. I originally wanted to separate the two files, but I thought it would be better to put
ExtJS has packaged components to achieve file upload function is very convenient, but for many ExtJS novice does not know how to control the file upload type, such as when we just want to let users upload ' txt ' type of files, how to achieve when
Nonsense does not say more directly to everyone paste JS code. The specific code looks like this:
web front end to the type size of the uploaded file >
The above is a small set to introduce the JS custom function of the Web
Use of Form form Upload file (type = "file"), Form form
1. Upload of a single file
1. html/jsp page
Insert title here upload a file
2. Filters solve Chinese garbled characters
package com.ser;import
The JS code is as follows:
function Checkfile (obj) {
var array = new Array (' GIF ', ' jpeg ', ' png ', ' jpg ');//Can be uploaded file type
if (Obj.value = = ") {
alert ("Let's choose the picture to upload!");
return false;
}
Php restricts the Upload file type and saves the uploaded file
The following code demonstrates how to obtain a user-uploaded file in php, limit the file type of a general image file, and save it to the server.
$
The code is as follows:Copy code // Obtain the image format, including jpg, png, and gif.Function get_type ($ img_name) // Obtain the image file type{If (preg_match ("/. (jpg | jpeg | gif | png | bmp) $/I", $ img_name, $ matches )){$ Type =
Upload file typeThe settings for the upload file type are configured in dokuwiki/conf/mime.conf.
If the old version is not supported, add the following in
The example in this article describes how PHP restricts uploading file types and saves uploaded files. Share to everyone for your reference. Specifically as follows:
The following code shows how to get the user to upload files in PHP, and limit the
Share to everyone php to judge upload file types of methods, we learn together.
/** * Read the first few bytes of the file to determine the file type * @return String/function Checktitle ($filename) {$file =fopen ($fi
Lename, "RB"); $bin
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.