Php+js upload, crop, preview, submit sample _php instances of the image

Source: Internet
Author: User
The first language to use is PHP, plugin imgareaselect (download address), not too many fancy styles, index.php code is as follows:
Copy CodeThe code is as follows:








<title>Picture cropping, previewing</title>


After uploading the picture, copy the picture 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); Put the uploaded file name as "." Good to do an array.
$time = Date ("M-d-h-i-s"); Take the current upload time
$filename [0] = $time; Take file name
$name = Implode (".", $filename); The file name after uploading
$uploadfile = $path. $name;
$_session[' upfile ' = $uploadfile;//file name address after upload
Move_uploaded_file ($tmp _addr, $uploadfile);
}
Echo $uploadfile;
}
?>





"title=" Mypic "/>





< div>


  • Related Article

    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.