2012-01-13 115 views
-1

我必須編寫一個php應用程序(讓我們稱之爲imagepath.php)來支持iphone/ipad應用程序。如何從php發送圖像路徑

Imagepath.php需要路徑www.xyz.com/whatever/image.jpeg

返回一個形象的例子在imagepath.php我能夠成功地從 這裏得到正確的圖片路徑是一個例子: http://cdn.svcs.x.y.com/c2/37a86590e709012e2fb300163e41dd5b

如果我發送這個路徑,因爲它是iPhone/iPad應用程序它不起作用,但如果我發送一個適當的圖像路徑,如www.xyz.com/whatever/image.jpeg它工作正常。

我該如何解決?

我當前的代碼

<?php 
.. 
.. 
.. 
// With some code above I am able to get image path in remote_img 
$remote_img = $results[1][0]; 
//send image out 
header('Content-Type: image/jpeg'); 
echo(file_get_contents($remote_img)); 
?> 

這裏是一個涉及到$ remote_img樣本圖像路徑 http://cdn.svcs.c2.uclick.com/c2/37a86590e709012e2fb300163e41dd5b

+2

歡迎來到stackoverflow!爲了解決你的問題而不訴諸球,我們需要看你當前的代碼(最好是[SSCCE](http://sscce.org/))。此外,演示問題的示例URL真的有幫助。 – phihag 2012-01-13 04:09:24

回答

0

當你做file_get_contents()

您的代碼應該工作原樣,只要 $remote_img是正確的
+0

它不起作用。但是,如果我發送固定的圖像路徑與.jpg結束它工作正常。 – user1146904 2012-01-13 05:51:07

+0

你可以使用CURL或者其他的東西,並且明白爲什麼它沒有獲取文件。 – Michael 2012-01-13 22:23:58

+0

由於應用程序正在期待一個JPEG鏈接。是否可以創建臨時圖像併發送它的鏈接?如果是這樣怎麼辦?如何刪除臨時圖像? – user1146904 2012-01-16 05:58:30