<!--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)