Home > php教程 > PHP源码 > 删除图片代码

删除图片代码

PHP中文网
Release: 2016-05-25 17:00:32
Original
1478 people have browsed it

项目中删除图片的代码,希望各位大大能给些安全性的建议。

if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
			$url = $_GET['json'];
			$url = $_SERVER['DOCUMENT_ROOT'].urldecode($url['picurl']);
			$pictype = array("gif","jpg","jpeg","png","bmp");
			if(file_exists($url)){
				$infos = pathinfo($url);
				if(in_array($infos['extension'],$pictype) && strpos($url,"uploadfile")){
					if(unlink($url)){
						echo json_encode(array("status"=>"1","info"=>L('删除成功!')));
					}else{
						echo json_encode(array("status"=>"2","info"=>L("删除失败,请检查权限!")));
					}
				}else{
					echo json_encode(array("status"=>"2","info"=>L("删除失败,请检查权限!")));
				}
				
			}else{
				echo json_encode(array("status"=>"0","info"=>L("文件不存在或已删除")));
			}
		}
Copy after login

                   


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template