我正在創建一個交友網站,用戶可以上傳他們的圖像, 一些私人和一些公衆。如何存儲和管理用戶的網站圖像
我打算做的是保存所有上傳的圖像,當我想要給他們看時,我將會有一個腳本來調用它們。
即:URL-> mysite.com/members/mainimage/5
處理這個調用該函數是: 公共職能mainImage($用戶){
$this->load->model('tables/user_images_table');
$image = $this->user_images_table->getMainUserImage($user);
if($image != null) {
$imageExploded = explode('.',$image);
switch($imageExploded[1]) {
case "gif": $ctype="image/gif"; break;
case "png": $ctype="image/png"; break;
case "jpeg":
case "jpg": $ctype="image/jpg"; break;
default:
}
$imagePath = 'uploads/'.$image;
} else {
//default image
$imagePath = 'inner/default.png';
$ctype = 'image/png';
}
header('Content-type: '.$ctype);
readfile(base_url()."images/".$imagePath);
}
但之後,我看到我的網站越來越大, 我注意到每個用戶圖像請求都加載了我的應用程序文件,並且可能會減慢我的網站速度。
你有任何想法如何保存專用的圖像(即不會將公開通過URL,只有經過用戶一些檢查)
例如Facebook:它使用圖像的隨機長名稱,您無法輕鬆預測圖案。 – 2013-02-02 21:25:02