[請益] 上傳圖片
我寫了一個PHP的網頁將圖片上傳到picture的資料夾
可是一直都沒有上傳成功
資料夾一直是空的
但是我一直找不到自己錯在哪裡>"<
請板上的各位大大能夠幫我解答
我用了三個檔案連結來上傳圖檔
原始碼有點長
<body>
<form action="fileboy.php" method="post" name="form1" enctype="multipart/form-data" class="style4">
<tr><td><div align="center" class="style2">照片上傳:</div>
<td><p align="left" class="style2">學號:
<input type=text name=id>
<p align="left" class="style2">
照片:
<input type=file name=upfile>
<p align="left">
<input type="submit" name="Submit" value="確定">
<input type="Reset" name="Reset" value="重新填寫">
<p align="center"><span class="style1">(檔案大小請勿超過100KB,尺寸300*400,類型為jpg檔)<br>
照片請上傳證件照<br>
(檔案名稱請以學號命名,如9212016.jpg)否則將直接刪除
</OL>
</table>
</center>
</span>
</form>
</form>
</p>
</body>
<?php
$Move='./picture';
$FILE_TYPES['JPG']=true;
$FILE_TYPES['JPEG']=true;
$FILE_SIZES['max']=1000000;
$FILE_SIZES['min']=0;
function inspect_file($strFileName, $intFilesize)
{
$arrSm=split('[.]', $strFileName);
$strEt=$arrSm[count($arrSm) - 1];
if($GLOBALS['FILE_TYPES'][strtoupper($strEt)]!=true)
{
return 1;
}
if($intFileSize < $GLOBALS['FILE_SIZES']['min'] || $intFileSize > $GLOBALS['FILE_SIZES']['max'])
{
return 2;
}
return0;
}
$intInspectResult = inspect_file($HTTP_POST_FILES['file']['name'], $HTTP_POST_FILES['file']['size']);
if($intInspectResult ==1)
{
echo "對不起,你的檔案上傳失敗,因為檔案類型錯誤<br>";
}
elseif($intInspectResult ==2)
{
echo "對不起,你的檔案上傳失敗,因為容量超出允許範圍<br>";
}
elseif ($intInspectResult ==0)
{
echo"檔案通過檢查<br>";
}
if(!(move_uploaded_file($HTTP_POST_FILES['upfile']['tmp_name'],$Move.$HTTP_POST_FILES['upfile']['name'])))
{
echo"檔案複製失敗,請重新上傳";
}
else
{
echo"檔案成功上傳";
}
?>
<div align="center"><a href="index.php"><img src="homebutton2.gif" width="88" height="35" border="0" /></a>
</div>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "" rel="nofollow">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="" rel="nofollow">http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<title>無標題文件</title>
</head>
<body>
<?php
require("db.php");
require("file2.php");
$aa="update 96new set
filename='$upfile_name'
where id='$id'";
$bb=mysql_query($aa);
?>
</body>
</html>
<?php
if($HTTP_POST_FILES['upfile']['size'] > 100000)
{
echo"檔案上傳失敗<br>";
echo"您上傳的檔案超過100KB了!!<br>";
}
else{
$userfile = $HTTP_POST_FILES['upfile']['name'];
$updata_dir="./picture";
$dest="$updata_dir/".$userfile;
move_uploaded_file($HTTP_POST_FILES['upfile']['tmp_name'],$dest);
echo"檔案上傳成功!!<br>";
}
?>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.217.225.250
推
08/11 20:04, , 1F
08/11 20:04, 1F
→
08/12 09:48, , 2F
08/12 09:48, 2F
討論串 (同標題文章)