About file Upload $ _ FILES! $ _ FILES [& quot; userfile & quot;] Here, userfile must be the front-end control name & lt; inputname = & quot; userfile & quot; type = & quot; file & quot;/& gt; the problem is. I used JS to obtain the file control about file Upload $ _ FILES!
$ _ FILES ["userfile"] Here, userfile must be the name of the front-end control.
The problem is. I use JS
Obtain the value of the file control userfile = document. getElementById ("userfile"). value;
Then use ajax to process it in the background
$. Ajax ({
Url: from. attr ('action '),
Data: "HeadImg =" + userfile + "",
Type: "post ",
DataType: "text ",
Success: function (data ){
Document. write (data );
// Alert (data)
If (data = "1 "){
Window. location. href ("home. php ");
}
}
});
Then the background
$ POST ['uploadmg '] can accept the value of userfile
$ _ FILES [$ POST ['uploadmg '] [temp_name] cannot be written in this way?
------ Solution --------------------
In this case, the client uploads files to the server through http post and stores them in the temporary directory of the server (php. ini). The file address is $ _ FILES ['updataheadimg '] ['tmp _ name'] (the file name is encrypted)
Move_uploaded_file () is used only to move files in the temporary directory to a new directory. In addition, the client can only upload files to the server, because the server cannot actively read files from the client.
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