Home > Backend Development > PHP Tutorial > Image processing software photoshop Ajax+PHP while learning and practicing Part 5 Image processing

Image processing software photoshop Ajax+PHP while learning and practicing Part 5 Image processing

WBOY
Release: 2016-07-29 08:41:19
Original
1170 people have browsed it

First the effect picture: Create Form in

 Ajax+PHP边学边练 之五 图片处理
Sample6_1.php:

Copy code The code is as follows:


//Display upload status and pictures


//Uploading files requires defining enctype, In order to display the image, set the target to uploadframe
enctype="multipart/form-data" target="uploadframe">
Upload a File:


//Upload file




Upload image function uploadimg:

Copy code The 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 code The code is as follows:


//Provide image type verification
$allowedtypes = array("image/jpeg ","image/pjpeg","image/png", "image/x-png","image/gif");
//File storage directory
$savefolder = "images";
//If there are files uploaded Let’s start working
if (isset ($_FILES['myfile'])){
//Check whether the uploaded file matches the $allowedtypes type
if (in_array($_FILES['myfile']['type'],$allowedtypes )){
if ($_FILES['myfile']['error'] == 0){
$thefile = "$savefolder/".$_FILES['myfile']['name'];
//Pass move_uploaded_fileUpload file
if (!move_uploaded_file($_FILES['myfile']['tmp_name'], $thefile)){
echo "There was an error uploading the file.";
}
else{
?>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns="http://www.w3.org/1999/xhtml">







}
}
}
}
?>


The doneloading function in the last part of the above code is used to display images and modify the image size. Thumb.php will be used, which will generate three sizes of large, medium and small source images in the images directory. If you are interested, you can study it. Welcome everyone to make bricks ~
The source code in the article is packaged and downloaded

The above introduces the image processing software photoshop Ajax+PHP while learning and practicing Part 5 Image processing, including the content of the image processing software photoshop. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template