如何使用Jcrop update Coords php更新mysql blob中的图像 问题很清楚,谢谢你的反馈
我想用php和jcrop在square裁剪后在mysql上传图像 我有这种类型的代码,但它不是写plz帮助我 HTML 剧本如何使用Jcrop update Coords php更新mysql blob中的图像 问题很清楚,谢谢你的反馈,php,mysql,blob,crop,jcrop,Php,Mysql,Blob,Crop,Jcrop,我想用php和jcrop在square裁剪后在mysql上传图像 我有这种类型的代码,但它不是写plz帮助我 HTML 剧本 <script type='text/javascript' src="http://jcropcdn.tapmodo.com/v0.9.12/js/jquery.Jcrop.min.js"></script> <link rel="stylesheet" type="text/css" href="http://jcropcdn.tapmo
<script type='text/javascript' src="http://jcropcdn.tapmodo.com/v0.9.12/js/jquery.Jcrop.min.js"></script>
<link rel="stylesheet" type="text/css" href="http://jcropcdn.tapmodo.com/v0.9.12/css/jquery.Jcrop.min.css">
<style type='text/css'>
#blah {
background-color: #000;
width: 500px;
font-size: 24px;
display: block;
}
</style>
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#blah').attr('src', e.target.result);
$('.crop').Jcrop({
onSelect: updateCoords,
bgOpacity: .4,
setSelect: [ 500, 10, 10, 10 ],
aspectRatio: 16 / 16
});
}
reader.readAsDataURL(input.files[0]);
}
}
$("#userImage").change(function(){
console.log(this);
readURL(this);
});
function updateCoords(c)
{
console.log(c);
$('#x').val(c.x);
$('#y').val(c.y);
$('#w').val(c.w);
$('#h').val(c.h);
};
});//]]>
</script>
我认为Upload.PHP不起作用
<?php
$max_file_size = 1000 * 1024;
if(count($_FILES) > 0) {
if(is_uploaded_file($_FILES['userImage']['tmp_name'])) {
if (! $_FILES['image']['error'] && $_FILES['image']['size'] < $max_file_size) {
$conn = mysql_connect("LOCAL", "USERNAME", "PASSWORD");
mysql_select_db("DB NAME");
$nw = $nh = 200;
$x = (int) $_POST['x'];
$y = (int) $_POST['y'];
$w = (int) $_POST['w'] ? $_POST['w'] : $size[0];
$h = (int) $_POST['h'] ? $_POST['h'] : $size[1];
$data = addslashes(file_get_contents($_FILES['userImage']['tmp_name']));
$vImg = imagecreatefromstring($data);
$dstImg = imagecreatetruecolor($nw, $nh);
$imgData = imagecopyresampled($dstImg, $vImg, 0, 0, $x, $y, $nw, $nh, $w, $h);
$imageProperties = getimageSize($_FILES['userImage']['tmp_name']);
$imgt = $imageProperties['mime'];
$stet = $_POST['stet'];
$sql ="UPDATE users SET
imageType='$imgt',
imageData='$imgData',
stet='$stet'
WHERE id=" . $_SESSION['user']['id'];
$current_id = mysql_query($sql) or die("<b>Error:</b> Problem on Image Insert<br/>" . mysql_error());
if(isset($current_id)) {
header("Location: index.php");
}
}
else
{
echo 'file is too small or large';
}
}}
?>
这个代码有什么问题吗?请快速给我定义
我想在jcrop之后使用php将图像存储在MySQL BLOB中。在顶部文件中写入错误报告。所以你会得到错误。问题是图像没有通过这种方式上传到mysql。你的代码中有SQL注入漏洞。什么浏览器抛出错误?我想在jcrop之后使用php将图像存储到mysql BLOB中。。
<?php
$max_file_size = 1000 * 1024;
if(count($_FILES) > 0) {
if(is_uploaded_file($_FILES['userImage']['tmp_name'])) {
if (! $_FILES['image']['error'] && $_FILES['image']['size'] < $max_file_size) {
$conn = mysql_connect("LOCAL", "USERNAME", "PASSWORD");
mysql_select_db("DB NAME");
$nw = $nh = 200;
$x = (int) $_POST['x'];
$y = (int) $_POST['y'];
$w = (int) $_POST['w'] ? $_POST['w'] : $size[0];
$h = (int) $_POST['h'] ? $_POST['h'] : $size[1];
$data = addslashes(file_get_contents($_FILES['userImage']['tmp_name']));
$vImg = imagecreatefromstring($data);
$dstImg = imagecreatetruecolor($nw, $nh);
$imgData = imagecopyresampled($dstImg, $vImg, 0, 0, $x, $y, $nw, $nh, $w, $h);
$imageProperties = getimageSize($_FILES['userImage']['tmp_name']);
$imgt = $imageProperties['mime'];
$stet = $_POST['stet'];
$sql ="UPDATE users SET
imageType='$imgt',
imageData='$imgData',
stet='$stet'
WHERE id=" . $_SESSION['user']['id'];
$current_id = mysql_query($sql) or die("<b>Error:</b> Problem on Image Insert<br/>" . mysql_error());
if(isset($current_id)) {
header("Location: index.php");
}
}
else
{
echo 'file is too small or large';
}
}}
?>