使用我在网站上看到的PHP编码上传文件,但它给出了错误解析错误:语法错误,第24行的C:\ xampp \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ [英] Uploading files with PHP coding I saw on a site but it is giving me error parse error: syntax error, unexpected 'else' (T_ELSE) in C:\xampp\htdocs\go.php on line 24

查看:84
本文介绍了使用我在网站上看到的PHP编码上传文件,但它给出了错误解析错误:语法错误,第24行的C:\ xampp \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?php
	if(isset($_FILES["photo"]["error"])){
		if($_FILES["photo"]["error"]>0){
			echo "Error:".$_FILES["photo"]["error"]."<br>";
		}else{
			$allowed=array("jpg"=>"image/jpg","jpeg"=>"image/gif","png"=>"image/png");
			$filename=$_FILES["photo"]["name"];
			$filetype=$_FILES["photo"]["type"];
			$filesize=$_FILES["photo"]["size"];
			
			$ext=pathinfo($filename, PATHINFO_EXTENSION);
			if(!array_key_exists($ext,$allowed)) die("Error: Please select a valid file format.");
			
			$maxsize=5*1024*1024;
			if($filesize>$maxsize) die("Error: File size is larger than the allowed limit");
			
			
			if(in_array($filetype,$allowed)){
				if(file_exists("upload/".$_FILES["photo"]["name"])){
					echo $_FILES["photo"]["name"]."is already exists.";
				}else{
					move_uploaded_file($_FILES["photo"]["tmp_name"],"upload/".$_FILES["photo"]["name"]);
					echo "your file was uploaded successfully";
				} else{
            echo "Error: There was a problem uploading your file - please try again."; 
        }
    }
} else{
    echo "Error: Invalid parameters - please contact your server administrator.";
}
?>





< b>我尝试了什么:



i什么都没试过,我想知道第一个IF的意思和第二个IF



What I have tried:

i have tried nothing and i would like to know the meaning of the very first IF and the second IF

推荐答案

_FILES [ photo] [< span class =code-string> error])){
if(
_FILES["photo"]["error"])){ if(


_FILES [ photo] [ 错误]> 0){
echo 错误:
_FILES["photo"]["error"]>0){ echo "Error:".


_FILES [ photo] [ error]。 <峰; br>中;
}其他{
_FILES["photo"]["error"]."<br>"; }else{


这篇关于使用我在网站上看到的PHP编码上传文件,但它给出了错误解析错误:语法错误,第24行的C:\ xampp \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆