Php+jquery online Map code [imitation Dedecms]

Source: Internet
Author: User
Tags php file

Php+jquery online Map code [anti-DEDECMS]
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title>Cropper</title>
<!--CSS-->
<link rel= "stylesheet" type= text/css "href=" http://yui.yahooapis.com/combo?2.6.0/build/reset-fonts-grids/ Reset-fonts-grids.css "/>
<link rel= "stylesheet" type= text/css "href=" http://yui.yahooapis.com/2.5.2/build/resize/assets/skins/sam/ Resize.css "/>
<link rel= "stylesheet" type= text/css "href=" http://yui.yahooapis.com/2.5.2/build/imagecropper/assets/skins/ Sam/imagecropper.css "/>
<!--JS-->
<script type= "Text/javascript" src= "http://yui.yahooapis.com/combo?2.5.2/build/yahoo-dom-event/ yahoo-dom-event.js&2.5.2/build/dragdrop/dragdrop-min.js&2.5.2/build/element/element-beta-min.js& 2.5.2/build/resize/resize-beta-min.js&2.5.2/build/imagecropper/imagecropper-beta-min.js&2.5.2/build/ Connection/connection-min.js&2.5.2/build/json/json-min.js "></script>

<style type= "Text/css" >
A:link, a:visited, a:active{
Color: #000;
Text-decoration:none;
Font-weight:bold;
}

a:hover{
Color: #fff;
Background-color: #000;
}

#hd {
Font-size:2em;
Font-weight:bold;
Text-align:left;
padding-bottom:20px;
border-bottom:1px solid #ccc;
margin:10px 0 10px 0;
}

#uploadForm, #downloadLink {
Text-align:center;
}

#imageContainer {
margin:20px 0px 20px 0;
}

#ft {
margin-top:10px;
padding-top:10px;
border-top:1px solid #ccc;
Text-align:center;
}
</style>

<script type= "Text/javascript" >
uploader = {
Carry:function () {
Set form
YAHOO.util.Connect.setForm (' Uploadform ', true);
Upload image
YAHOO.util.Connect.asyncRequest (' POST ', ' upload.php ', {
Upload:function (o) {
Parse our JSON data
var jsondata = YAHOO.lang.JSON.parse (O.responsetext);

Put image in my our image container
YAHOO.util.Dom.get (' Imagecontainer '). InnerHTML = '
init our Photoshop
Photoshop.init (Jsondata.image);

Get cropped image
Photoshop.getcroppedimage ();
}
});
}
};

Photoshop = {
Image:null,
Crop:null,
Url:null,

Init:function (image) {
Set our image
Photoshop.image = image;

Our image cropper from the uploaded image
Photoshop.crop = new YAHOO.widget.ImageCropper (' yuiimg ');
Photoshop.crop.on (' Moveevent ', function () {
Get updated coordinates
Photoshop.getcroppedimage ();
});
},

Getcroppedimage:function () {
var coordinates = photoshop.getcoordinates ();
var url = ' crop.php?image= ' + photoshop.image + ' &cropstartx= ' + coordinates.left + ' &cropstarty= ' + coordinates.to p + ' &cropwidth= ' + coordinates.width + ' &cropheight= ' + coordinates.height;
YAHOO.util.Dom.get (' Downloadlink '). InnerHTML = ' <a href= ' + URL + ' >download cropped ';
},

Getcoordinates:function () {
return Photoshop.crop.getCropCoords ();
}
};

Add listeners
YAHOO.util.Event.on (' Uploadbutton ', ' click ', Uploader.carry);
</script>
<body class= "Yui-skin-sam" >
<div id= "doc4" class= "Yui-t7" >
<div id= "HD" >
AJAX Image cropper-yui-based
</div>

<div id= "BD" >
<form action= "upload.php" enctype= "Multipart/form-data" method= "post" name= "Uploadform" id= "UploadForm" >
Image: <input type= "file" Name= "Uploadimage" id= "Uploadimage"/>
<input type= "button" id= "Uploadbutton" value= "Upload"/>
</form>

<div id= "Imagecontainer" ></div>

<div id= "Downloadlink" ></div>
</div>

<div id= "FT" >
<a href= "Http://htmlblog.net" >html blog</a>
</div>
</div>
</body>
The index.php file above
Based on x,y, to use PHP to re-draw

<?php
Get variables
$imgfile = $_get[' image '];
$cropStartX = $_get[' Cropstartx '];
$cropStartY = $_get[' Cropstarty '];
$cropW = $_get[' cropwidth '];
$cropH = $_get[' cropheight '];

Create two images
$origimg = Imagecreatefromjpeg ($imgfile);
$cropimg = Imagecreatetruecolor ($cropW, $cropH);

Get the original size
List ($width, $height) = getimagesize ($imgfile);

Crop
Imagecopyresized ($cropimg, $origimg, 0, 0, $cropStartX, $cropStartY, $width, $height, $width, $height);

Force download NES image
Header ("Content-type:image/jpeg");
Header (' Content-disposition:attachment filename= '; $imgfile. ' ");
Imagejpeg ($CROPIMG);

Destroy the images
Imagedestroy ($CROPIMG);
Imagedestroy ($ORIGIMG);
?>

This is in the picture,

<?php

if (!empty ($_files["Uploadimage"])) {
Get file name
$filename = basename ($_files[' uploadimage '] [' name ']);

Get extension
$ext = substr ($filename, Strrpos ($filename, '. ') + 1);

Check for JPG
if ($ext = = "jpg") {
Generate Unique file name
$newName = ' images/'. Time (). $ext;

Upload files
if ((Move_uploaded_file ($_files[' uploadimage '] [' tmp_name '], $newName))) {

Get height and width for image uploaded
List ($width, $height) = getimagesize ($newName);

Return JSON data
Echo ' {' image ': '. $newName. ', ' height ': '. $height. ', ' width ': '. $width. ' "} ';
}
else {
Echo ' {' Error ': ' An error occurred while moving the ' files '} ';
}
}
else {
Echo ' {' Error ': ' Invalid image format '} ';
}
}
?>

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.