我想移動一個已經使用imagettftext創建並保存爲png的文件。如您所見,在下面的代碼中,我使用了move_uploaded_file,但無濟於事。請幫忙。移動上傳的文件php不工作
TQ
// Set the content-type
header('Content-Type: image/png');
// Create the image from created image
//$im = imagecreatetruecolor(180, 180);
$im = @imagecreatefromjpeg('poloroid.jpg');
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
//imagefilledrectangle($im, 0, 0, 399, 29, $white);
// The text to draw
//$text = 'John...';
$fbid = $_POST["id"];
$text = $_POST["want"];
$fb_email =$_POST["email"];
$fb_name=$_POST["name"];
$uploads_dir = '/uploaded_files';
// Replace path by your own font path
$font = 'verdana.ttf';
//image file name
$name ="$fbid.png";
// Add some shadow to the text
imagettftext($im, 20, 0, 25, 126, $grey, $font, $text);
// Add the text
imagettftext($im, 20, 0, 25, 125, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
//imagepng($im);
imagepng($im,$name,9);
move_uploaded_file($name,"$uploads_dir/$name");
imagedestroy($im);
刪除'@'從'imagecreatefromjpeg符號()',看看你得到任何錯誤,還要確保'error_reporting'處於打開狀態。 –
move_uploaded_file只移動通過表單上傳的文件,您應該使用函數[rename](http://php.net/manual/en/function.rename.php) –