作者warke (饒輝)
看板PHP
標題Re: [請益]關於上傳
時間Thu Aug 28 17:03:50 2008
※ 引述《chobitsppc (無止盡的道路)》之銘言:
可以從這邊找到答案:
http://tw.php.net/manual/en/function.is-uploaded-file.php
if (is_uploaded_file($userfile)) {
//include code to copy tmp file to final location here...
}else{
switch($HTTP_POST_FILES['userfile']['error']){
case 0:
//no error; possible file attack!
echo "There was a problem with your upload.";
break;
case 1:
//uploaded file exceeds the upload_max_filesize directive in php.ini
echo "The file you are trying to upload is too big.";
break;
case 2:
//uploaded file exceeds the MAX_FILE_SIZE directive that was
//specified in the html form
echo "The file you are trying to upload is too big.";
break;
case 3:
//uploaded file was only partially uploaded
echo "The file you are trying upload was only partially uploaded.";
break;
case 4:
//no file was uploaded
echo "You must select an image for upload.";
break;
default:
//a default error, just in case! :)
echo "There was a problem with your upload.";
break;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 203.222.26.129
1F:推 chobitsppc :感謝warke大的回答,我印出的結果是 08/28 17:17
2F:→ chobitsppc :There was a problem with your upload 08/28 17:17
3F:→ chobitsppc :原文的意思是可能檔案有問題嗎? 08/28 17:19
4F:推 allen501pc :應該是 enctype="multipart/form-data",上一篇有錯 08/28 18:13
5F:→ chobitsppc :感謝allen501pc~有時候真的是會鬼打牆啊...囧rz 08/28 19:11
6F:推 allen501pc :不客氣。 08/28 20:57