2012-06-20 43 views
0

我已創建了一個圖像 但問題是,當我保存的圖像從瀏覽器,它保存爲image.php,但我想將其保存爲自定義名稱從PHP發送名稱後保存在用戶瀏覽器中的圖像

<?php 

$my_img = imagecreatefromjpeg("images/photo.jpg"); 
$nw = 400; 
$nh = 500; 
$img2 = imagecreatetruecolor($nw, $nh); 
imagecopyresampled($img2, $my_img, 0, 0, 0, 0, $nw, $nh, imagesx($my_img), imagesy($my_img)); 

header("Content-type: image/jpeg"); 
header('filename="Custome Name.jpeg"'); 
imagejpeg($img2,NULL,60); 
imagedestroy($img2); 
?> 

當用戶將保存的圖像,必須保存爲從服務器

回答

0

基礎上bsdnoobz回答,請嘗試使用在線價值內容處置

header('Content-Disposition: inline; filename="custom_name.jpg"'); 

代替:

header('filename="Custome Name.jpeg"'); 
1

發送名稱替換這一行,

header('filename="Custome Name.jpeg"'); 

header('Content-Disposition: attachment; filename="custom_name.jpg"'); 
+0

如果我這樣做將開始下載 –

+0

我想將其顯示在瀏覽器中,但用戶保存時,必須將其另存爲自定義名稱 –

相關問題