中顯示上傳狀態
setStatus ("Loading...","showimg");
} //上傳狀態函數
function setStatus (theStatus, theObj){
obj = document.getElementById(theObj);
if (obj){ obj.nerHTML - " + theStatus + "
"; } }
process_upload.php 提供檔案上傳功能:
複製程式碼
程式碼如下:
//提供圖片類型校驗
$allowedtypes = array("image/ jpeg","image/pjpeg","image/png", "image/x-png","image/gif");
//檔案存放目錄
$savefolder = "images";
//如果有檔案上傳就開始工作
if (isset ($_FILES['myfile'])){
//檢查上傳檔案是否符合$allowedtypes類型
if (in_array($_FILES ['myfile']['type'],$allowedtypes)){
if ($_FILES['myfile']['error'] == 0){
$thefile = "$savefolder/". $_FILES['myfile']['name'];
//透過move_uploaded_file上傳檔案
if (!move_uploaded_file($_FILES['myfile']['tmp_name'], $thefile)){
echo "There was an error uploading the file.";
}
else{
?>
BR>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
} }
}
}
?>
上面程式碼最後部分的doneloading 函數就是用來顯示圖片、修改圖片尺寸大小。其中會用到thumb.php,它會在images目錄中產生出來源圖片的大、中、小三個尺寸,有興趣可以研究一下。歡迎大家拍磚~ 文中源碼打包下載
以上就介紹了影像處理軟體photoshop Ajax+PHP邊學邊練 之五 圖片處理,包括了影像處理軟體photoshop方面的內容,希望對PHP教學有興趣的朋友有所幫助。