Php image file upload details _ PHP Tutorial

Source: Internet
Author: User
Tags file upload script
Php image file upload for detailed analysis. Upload_err_oknoerroccurred. Upload success tutorial. inifile. The maximum upload size is exceeded. upload_e upload_err_ OK no error occurred.

Uploaded

Upload_err_ini_size the uploaded file exceeds the maximum value specified in the php Tutorial. ini file.
Maximum upload size exceeded

Upload_err_form_size the uploaded file exceeds the maximum value specified by the max_file_size hidden widget.
The maximum size of the form file is exceeded.

Upload_err_partial the file upload was canceled and only part of the file was uploaded.

Upload_err_nofile no file was uploaded.

File Not uploaded



A simple file upload form




Instance 1

]

A file upload script



If (isset ($ _ files ['fupload']) {

Print "name:". $ _ files ['fupload'] ['name']."
";
Print "size:". $ _ files ['fupload'] ['size']. "bytes
";
Print "temp name:". $ _ files ['fupload'] ['tmp _ name']."
";
Print "type:". $ _ files ['fupload'] ['type']."
";
Print "error:". $ _ files ['fupload'] ['error']."
";

If ($ _ files ['fupload'] ['type'] = "image/gif "){

$ Source = $ _ files ['fupload'] ['tmp _ name'];
$ Target = "upload/". $ _ files ['fupload'] ['name'];
Move_uploaded_file ($ source, $ target); // or die ("couldn't copy ");
$ Size = getimagesize ($ target );

$ Imgstr ="

$ Imgstr. = "src =" $ target "alt =" uploaded image "/>

";

Print $ imgstr;
}
}
?>




File upload instance 2

$ Maxsize = 28480;
If (! $ Http_post_vars ['submit ']) {
$ Error = "";
}
If (! Is_uploaded_file ($ http_post_files ['upload _ file'] ['tmp _ name']) and! Isset ($ error )){
$ Error ="You must upload a file!

";
Unlink ($ http_post_files ['upload _ file'] ['tmp _ name']);
}
If ($ http_post_files ['upload _ file'] ['size']> $ maxsize and! Isset ($ error )){
$ Error ="Error, file must be less than $ maxsize bytes.

";
Unlink ($ http_post_files ['upload _ file'] ['tmp _ name']);
}
If (! Isset ($ error )){
Move_uploaded_file ($ http_post_files ['upload _ file'] ['tmp _ name'],
"Uploads/". $ http_post_files ['upload _ file'] ['name']);
Print "thank you for your upload .";
Exit;
}
Else
{
Echo ("$ error ");
}
?>







Http://www.bkjia.com/PHPjc/444783.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/444783.htmlTechArticleupload_err_ OK no error occurred. Upload successful upload_err_ini_size the uploaded file exceeds the maximum value specified in the php Tutorial. ini file. the maximum upload size is exceeded upload_e...

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.