写真をアップロードするためのコードがあります。写真がアップロードされると、ユーザーはそれを切り取ることができます。次に、ピクチャは で呼び出され$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")
。最後のエコーが原因で、外側にあり、すべて機能しますが、内側のエコーでは何も機能しません。しかし、まだ何が悪いのかわかりません...
<?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;
?>