<?php
if(isset($_POST['submitted'])){
if(isset($_FILES['upload'])){
$allowed=array('image/pjepg','image/jpeg','image/JPG','image/X-PNG','image/PNG','image/png');
if(in_array($_FILES['upload'][type],$allowed)){
if(move_uploaded_file($_FILES['upload']['tmp_name'],"../upload/{$_FILES['upload']['name']}")){
echo '<p><em> The file has been uploaded!</em></p>';
}
else {
echo '<p class="error">Please upload a JPEG or PNG image. </p>';
}
}
isset($_FILES['upload'])
if($_FILES['upload']['error']>0){
echo '<p class="error">The file could not be uploaded because: <strong>';
switch ($_FILES['upload']['error']) {
case 1:
print 'the file exceeds the upload_max_filesize setting in php.ini.';
break;
case 2:
print 'the file exceeds the MAX_FILE_SIZE setting in HTML form.';
break;
case 3:
print 'the file was only partially uploaded.';
break;
case 4:
print 'No file was uploaded.';
break;
case 5:
print 'No temporary folder was availiable.';
break;
case 6:
print 'Unable to write to the disk.';
break;
case 7:
print 'File uploaded stopped.';
break;
default:
print 'A system error occurred.';
break;
}
print '</strong></p>';
}
if((file_exists($_FILES['upload']['tmp_name'])) && (is_file($_FILES['upload']['tmp_name']))){
unlink($_FILES['upload']['tmp_name']);
}
}
?>
when i run this i get:
当我运行这个时,我得到:
Parse error: syntax error, unexpected T_IF in C:\wamp\www\project\uploadctrl.php on line 15
解析错误:语法错误,在C:\wamp\ \www\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \uploadctrl。php在第15行
and i cant find any errors in syntax..i search everything on code but i didnt find anything..anyone can help???
我在语法上找不到任何错误。我搜遍了所有的代码,但我什么也没找到。任何人都可以帮忙吗? ? ?
1 个解决方案
#1
1
Your:
你的:
isset($_FILES['upload'])
needs to be:
需要:
isset($_FILES['upload']);
It does say line 15, usually error lies just before that line.
它说的是第15行,通常错误就在这条线之前。
#1
1
Your:
你的:
isset($_FILES['upload'])
needs to be:
需要:
isset($_FILES['upload']);
It does say line 15, usually error lies just before that line.
它说的是第15行,通常错误就在这条线之前。