0
我想寫一個上傳函數,返回上傳文件的位置。該位置將被用於調用Imagick類的函數中,以重新調整圖像幾次以用於響應式設計。唯一的問題是......我沒有從return語句中得到任何答案,也找不到原因。 Heeeelp! *在我剜了我的眼睛函數不返回變量
HERE'S *
function imageResize($image){
//call to imagick class and resize functions will go here
echo 'the image to be resized is : '.$image;
}
function file_upload(){
if(!empty($_FILES)){
$tmpFldr=$_FILES['upFile']['tmp_name'];
$fileDest='users/uploads/'.$_FILES['upFile']['name'];
if(move_uploaded_file($tmpFldr,$fileDest)){
echo 'Congratulations, your folder was uploaded successfully';
}
else{
echo 'Your file failed to upload<br><br>';
}
return $fileDest;
} else{die('Nothing to upload');}
} /*End file upload function */
file_upload();
imageResize($fileDest);
在'if'語句中返回通常不是一個好主意,你最好使用一個變量來存儲你想返回的結果,並在函數結尾處返回該變量。 – lascort