It's a note. In fact, the entire program has been written, although a little ugly, but it's okay .. after all, it is the first program written by myself... the whole system only uses PHP with codes, no JS, no regular expressions... pure PHP... in fact, I will not...
Below is the html code of the original form...
Upload file Form
The code is as follows:
In the form, enctype = "multipart/form-data" indicates the MIME encoding of the form. By default, the encoding format is application/x-www-form-urlencoded and cannot be used for file upload. only multipart/form-data can be used to completely transmit file data, perform the following operations. enctype = "multipart/form-data" is used to upload binary data. the values in form are passed in a binary stream.
This sentence seems useless... I thought this could limit the size of the uploaded file. The size of the uploaded file is only in php. in ini or in the script of the file to be uploaded later, you have set up... in my program, php is directly set. in ini, upload_max_filesize = 6 m.
Below is the upload program
Code
The code is as follows:
$ Uploaddir = "./map /";
$ Typearr = array ("rar", "zip", "w3m", "w3x ");
$ Findstr = array ("/", "\", "", "<", ">"); // filter the name
$ Mapname = str_replace ($ findstr, '', ($ _ POST ['mapname']);
// Get the extension
Function upfiletype ($ filename ){
$ Arr = explode ('.', $ filename );
$ A = count ($ arr)-1;
Return $ arr [$ a];
}
// Whether the string is a pure number
Function isNo ($ str ){
$ Intarr = array ('1', '2', '3', '4', '5', '6', '7', '8 ', '9', '0 ','. ');
$ A = str_replace ($ intarr, '', $ str );
Return ($ a = "")? 1:0;
}
///// Control the window size ///////
Function html (){
Echo <
File Upload
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.