Home >Backend Development >PHP Tutorial > php修改写入路径解决方案

php修改写入路径解决方案

WBOY
WBOYOriginal
2016-06-13 13:42:521386browse

php修改写入路径

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
<?php function getImage($url,$filename="",$ext) { 
  if(!$url) return false;

  $filename=date("dMYHis").$ext; 

  ob_start(); 
  readfile($url); 
  $img = ob_get_contents(); 
  ob_end_clean(); 
  $fp2=@fopen($filename, "a"); 
  fwrite($fp2,$img); 
  fclose($fp2); 

  return $filename; 
} 
$link=$_GET['url'];
$ext=$_GET['ext'];

$img=getImage("$link","","$ext");

if($img)
echo "<p>".$img."<br><a href=".%24img.">Enter</a>";
else
echo "false<br>url<br>ext<br>";
?>



目前可以传入连接和文件类型,我想再添加写入路径的话怎么改
例如可以自定义写入路径 $path=$_GET['path'];

------解决方案--------------------
$link 这个不就是你的路径?
Statement:
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