2016-06-07 75 views
0

我使用圖像水印php腳本,我在這裏從https://www.sanwebe.com/2014/08/watermark-an-uploaded-image-with-php得到參考。上傳圖片的圖片水印?

問題是:

imagecopy($new_canvas, $watermark, $watermark_left, $watermark_bottom, 0, 0, 300, 100); 

這是添加成功水印圖像,當我使用:

//output image direcly on the browser. 
header('Content-Type: image/jpeg'); 
imagejpeg($new_canvas, NULL , 90); 

它打印圖像與水印,但我不能上傳圖片與水印,我用:

move_uploaded_file($temp_name, $destination_path); 

上傳圖片成功,但沒有水印和

move_uploaded_file($new_canvas, $destination_path); 

它給錯誤:

Warning: move_uploaded_file() expects parameter 1 to be string, resource given.

請幫我解決這個問題。

+1

呃,'$ new_canvas'應該是一個字符串。 –

+0

不,它是資源ID。 –

+0

@JayDeepNimavat是的,它應該是一個字符串。文件名更具體。 – Chris

回答

2

使用「imagejpeg」可以將圖像輸出到瀏覽器或文件。要將圖像保存到文件中,請嘗試以下操作:

imagejpeg($new_canvas, $destination_path , 90); 
+0

謝謝它適合我。 –