PHP File Upload Class (page and call parts)

Source: Internet
Author: User
Tags php file upload

<!--upform.html Content--

<form action= "upload.php" method= "post" enctype= "Multipart/form-data" >
Name: <input type= "text" name= "username" value= "/><br>
<input type= "hidden" name= "max_file_size" value= "1000000"/>
Up Pic: <input type= "file" name= "pic[" "value=" "><br>
Up Pic: <input type= "file" name= "pic[" "value=" "><br>
Up Pic: <input type= "file" name= "pic[" "value=" "><br>
Up Pic: <input type= "file" name= "pic[" "value=" "><br>

<input type= "Submit" value= "Upload"/><br>

</form>

<!--upload.php Content--

<?php
Contains a file Upload class
Include "fileupload.class.php";

$up = new FileUpload;
Set properties (upload location, size, type, whether the name should be randomly generated)
$up, set ("Path", "./images/");
$up, set ("MaxSize", 2000000);
$up, set ("Allowtype", Array ("GIF", "png", "JPG", "jpeg"));
$up, set ("Israndname", false);

Using the Upload method in the object, you can upload the file, the method needs to pass an upload form the name of the PIC, if successful returns TRUE, the failure returns false
if ($up-Upload ("pic")) {
Echo ' <pre> ';
Get file name after upload
Var_dump ($up->getfilename ());
Echo ' </pre> ';

} else {
Echo ' <pre> ';
Get an error message after uploading failed
Var_dump ($up->geterrormsg ());
Echo ' </pre> ';
}

PHP File Upload Class (page and call parts)

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.