【发布时间】:2016-10-31 08:02:49
【问题描述】:
我正在尝试创建图像叠加应用程序,它将为上传的图像添加水印。我已经使用这个tutorial 完成了我的图像叠加应用程序, 现在我需要使用croppie.js 添加裁剪功能。我想将croppie js的输出传递给这个php。
<?php
# Check to see if the form has been submitted or not:
if( !isset( $_POST['submit'] ) ){
# Form has not been submitted, show our uploader form and stop the script
require_once( "uploader.html" );
exit();
}else{
# Form has been submitted, begin processing data
# Include the function file then call it with the uploaded picture:
# TIP: The "../../ portion is a relative path. You will need to change this
# path to fit your website's directory structure.
require_once( 'FacebookPicOverlay.php' );
# Create the FacebookTagger object using our upload value given to us by uploader.html
$fbt = new FacebookPicOverlay();
# Let's say we're using this script to do an image overlay. Let's invoke the
# overlay method, which will then return the image file relative to the resources
# folder (ex: will return resources/processed/imagename.jpg).
try {
$image = $fbt->overlay( $_FILES['picture_upload'] );
}catch( Exception $e ){
print( "<b>Oops!</b> " . $e->getMessage() );
print( "<br /><br /><a href=\"javascript:history.go(-1)\">Please go back and try again</a>" );
exit();
}
# This will delete all images created more than two days ago (by default).
# This is helpful in keeping our processed folder at a reasonable file size.
$fbt->maintenance();
require_once( "success.html" );
}
# That's all, folks!
?>
请帮我处理上传表单。谢谢
【问题讨论】:
-
没有表格,几乎没有代码。裁剪后,您可以将数据作为 blob 取出(例如,使用
canvas.getImageData)然后传递给 php 进行处理吗?这就是你需要做的所有事情,但提供的代码并没有告诉我们什么。
标签: javascript php jquery crop