First prev:
Create a form in sample6_1.php:
Copy CodeThe code is as follows:
Show upload status and pictures
The upload file needs to be defined enctype, in order to show the image set target to Uploadframe
Upload Image function Uploadimg:
Copy CodeThe code is as follows:
function Uploadimg (theform) {
Submit Form
Theform.submit ();
Show upload status in Showimg
SetStatus ("Loading ...", "showimg");
}
Upload status function
function SetStatus (thestatus, theobj) {
obj = document.getElementById (theobj);
if (obj) {
obj.innerhtml = "" + Thestatus + "";
}
}
process_upload.php provides file upload function:
Copy CodeThe code is as follows:
Provides a picture type check
$allowedtypes = Array ("Image/jpeg", "Image/pjpeg", "Image/png", "Image/x-png", "image/gif");
File storage Directory
$savefolder = "Images";
If there's a file upload, start working.
if (Isset ($_files[' myfile ')) {
Check if the upload file conforms to the $allowedtypes type
if (In_array ($_files[' myfile ' [' type '], $allowedtypes)) {
if ($_files[' myfile ' [' error '] = = 0) {
$thefile = "$savefolder/". $_files[' myfile ' [' name '];
Uploading Files via Move_uploaded_file
if (!move_uploaded_file ($_files[' myfile ' [' tmp_name '], $thefile)) {
echo "There is an error uploading the file.";
}
else{
?>
"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
"Onload=" doneloading (Parent, ' ') "/>
}
}
}
}
?>
The Doneloading function in the last part of the code above is used to display the image and modify the size of the image. Which will be used to thumb.php, it will be in the images directory to generate the source image of the large, medium and small three size, interested can be studied. Welcome everyone to shoot bricks ~
Text Source package Download
http://www.bkjia.com/PHPjc/320968.html www.bkjia.com true http://www.bkjia.com/PHPjc/320968.html techarticle First: Create form in sample6_1.php: Copy code code as follows://display upload status and picture div id= "showimg"/div//upload file need to define enctype, in order to display pictures ...