Home  >  Article  >  Backend Development  >  Example of uploading, cropping, previewing and submitting images using php+js_PHP tutorial

Example of uploading, cropping, previewing and submitting images using php+js_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 16:12:21832browse

The first language used is php and the plug-in imgareaselect (download address). There are not many fancy styles. The index.php code is as follows:

Copy code The code is as follows :









Image cropping, preview


//After uploading the image, copy the image to the upload folder
if($_POST){
$photo = $_FILES['img']['name'];
$tmp_addr = $_FILES['img']['tmp_name'];

$path = 'upload/';
$type=array("jpg","gif","jpeg ","png");
$tool = substr(strrchr($photo,'.'),1);
if(!in_array(strtolower($tool),$type)){
$text=implode('.',$type);
echo "You can only upload the following types of files: ",$text,"
";
}else{
$filename = explode(".",$photo); //Make an array of uploaded file names based on ".".
$time = date("m-d-H-i-s"); //Get the current upload time
$filename[0] = $time; //Get the file name
$name = implode(".",$ filename); //Uploaded file name
$uploadfile = $path.$name;
$_SESSION['upfile'] = $uploadfile; //Uploaded file name address
move_uploaded_file($ tmp_addr,$uploadfile);
}
// echo $uploadfile;
}
?>










< ;/div>



< div>


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/313687.htmlTechArticleThe first language used is php, plug-in imgareaselect (download address), there are not many fancy styles, index. The php code is as follows: Copy the code as follows: !DOCTYPE html PUBLIC "-//W3C//DTD...
Statement:
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