gpt4 book ai didi

javascript - MySQL值不显示在图片名称中

转载 作者:行者123 更新时间:2023-11-28 08:51:58 24 4
gpt4 key购买 nike

我有一个上传图片的代码。图片上传后,用户可以对其进行裁剪。然后,使用 $new_name 调用该图片。我遇到的唯一问题是,在 $new_name 中,$_GET['MomentEvent'] 永远不会出现在图片名称中。但是当我回显它时,它显示正常。那么,我怎样才能让它出现在 $new_name 中呢?

有关信息,MomentEvent 引用创建的每个新页面的唯一键。因此,当用户上传图片时,只会在页面上显示具有良好 MomentEvent 的图片。

编辑:看起来问题来自这一行:echo $new_name."?".time();,因为当我尝试仅 echo $_GET['MomentEvent'],什么也没发生。

编辑2:看起来问题来自if(isset($_GET['t']) and $_GET['t'] == "ajax"),因为最后一个 echo ,它在外面,并且一切正常,但是当 echo 在里面时,什么都不起作用。但我仍然不知道出了什么问题......

<?php
include('db.php');
session_start();
$session_id=$_SESSION['id']; // Or Session ID
$actual_image_name = time().substr($txt, 5).".".$ext;
$t_width = 450; // Maximum thumbnail width
$t_height = 150; // Maximum thumbnail height
$new_name = "$actual_image_name".$_GET['MomentEvent'].".jpg"; // Thumbnail image name
$path = "images/";

if(isset($_GET['t']) and $_GET['t'] == "ajax")
{

extract($_GET);
$ratio = ($t_width/$w);
$nw = ceil($w * $ratio);
$nh = ceil($h * $ratio);
$nimg = imagecreatetruecolor($nw,$nh);
$im_src = imagecreatefromjpeg($path.$img);
imagecopyresampled($nimg,$im_src,0,0,$x1,$y1,$nw,$nh,$w,$h);
imagejpeg($nimg,$path.$new_name,90);
mysql_query("UPDATE users_event SET image_small='$new_name' WHERE MomentEvent='".$_GET['MomentEvent']."'");
echo $new_name."?".time();
exit;
}
echo $new_name;
?>

最佳答案

不要使用提取物。通常使用它是不好的做法,但特别是在 _get 变量上......它会让您遭受 DOS 攻击,有人可以用数百个不需要的变量淹没您的查询字符串。

http://php.net/manual/en/function.extract.php

只需单独引用关联数组项即可。

关于javascript - MySQL值不显示在图片名称中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19041190/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com