這是唯一的代碼搞亂了PHP,我刪除它,它恢復完美,所以我猜這個循環語句內的東西是錯誤的;有人可以看看最新的錯誤?語法錯誤PHP(for循環)
以下假設要搜索文件夾並查看圖像是否已經在該文件夾中,如果是這樣,它每次將$ i +1($ i ++)變爲+1,然後再次檢查最大值爲30的數字。
任何想法我可以做到這一點? 錯誤我得到:
"HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request"
所以必須配置不正確
-php循環代碼
代碼中的東西<?php
define ("MAX_SIZE","100");
function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
$errors=0;
if(isset($_POST['Submit']))
{
$image=$_FILES['image']['name'];
if ($image)
{
$filename = stripslashes($_FILES['image']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
{
//print error message
echo "";
$errors=1;
}
else
{
$size=filesize(['image']['tmp_name']);
if ($size > MAX_SIZE*1024)
{
echo "";
$errors=1;
}
$image_name=time().'.'.$extension;
//Error Occurs Below
for($i=0; $i<30; $i++)
{
$relativePath="members/image/corey/"."photo".$i;
if(!file_exists($relativePath)) {
continue;
}
else
{
$newNumber=$i;
break;
}
}
$fileName=$_FILES["name"]."$newNumber";
$relativePath="members/image/corey/".$filename.'.'.$extension;
move_uploaded_file($image, $relativePath);
//Error Occurs Above
?>
-Buttons
<form name="newad" method="post" enctype="multipart/form-data" action="">
<table>
<tr><td><table>
<tr>
<td><input type="file" name="image" /></td>
</tr>
<tr>
<td><input name="Submit" id="upload" type="submit" value="Upload image" onclick"load_images()" /></td>
</tr>
</table></td></tr>
</table>
</form>
</div>
我已經撤銷了您最後的破壞性編輯。不要試圖以這種方式「關閉」問題。 – meagar 2012-03-09 00:35:33
好吧,我的壞。我已標記它也 – 2012-03-09 00:40:37