本文介绍了使用我在网站上看到的PHP编码上传文件,但它给出了错误解析错误:语法错误,第24行的C:\ xampp \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 <?phpif(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.";}?> 我尝试了什么: 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] [ 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 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-03 06:03