2012-07-13 106 views
0

我在這裏的腳本正常工作:與有空格的文件名處理

image protection in codeigniter

但是它會顯示一個破碎的形象,如果我的文件名中有空格,所以說這是「奧巴馬1.JPG」。

要嘗試解決這個問題,我已經使用http://php.net/manual/en/function.escapeshellarg.php

,代之以符合「%」 S的img_id所有的空格。

但我沒有運氣。我無法將白色空間去掉,所以必須根據字符串的結構來製作。

感謝您的幫助。

+0

如果它在'file_exists($ filepath)'處被解僱,並且$ filepath應該是一個url,那麼也許你應該'rawurlencode'這個文件名。 http://ca2.php.net/manual/en/function.rawurlencode.php – dnagirl 2012-07-13 13:32:17

回答

2

當你調用圖像只使用

echo urlencode($image_name); 

這應該修復它!

+0

$ url = $ this-> data ['base_url']。'system/application/images/c/thumbs /'; \t $ filepath = $ url.urlencode($ img_id); 我試過了,仍然有一個破碎的圖像。它增加了%20,所以「obama%201.jpg」就是這樣。 – thejoker 2012-07-16 10:28:16

+0

我在我的控制器類中卡住了這個。 – thejoker 2012-07-16 12:28:37

+0

請選擇此項作爲答案,如果它幫助:) – Kush 2012-07-18 20:04:35

0

如果您使用的URL中的文件名試圖用20%替代空間,因此「奧巴馬%201.jpg」

相關問題