Heim  >  Artikel  >  Backend-Entwicklung  >  [代码]PHP上传图片简单实现_PHP教程

[代码]PHP上传图片简单实现_PHP教程

WBOY
WBOYOriginal
2016-07-13 17:30:42766Durchsuche

    以下程序使用move_uploaded_file函数上传图片到程序目录中,图片以temp_为前缀。

以下是代码片段:
 
 
php<font class="reblank">(做为现在的主流开发语言)</font>上传图片简单实现 www.cncms.com.cn 
 
 
(做为现在的主流开发语言) 
if($_GET[’action’] == ’upfile’) 

$target_path = ’temp_’.$_FILES[’photo’][’name’]; 
echo ’上传的临时文件:’ .$_FILES[’photo’][’tmp_name’] . ’
’;
echo ’上传的目标文件:’ .$target_path . ’
’;
echo $_SERVER["SCRIPT_FILENAME"] . ’
’;
echo $_SERVER["OS"] . ’
’;
//测试函数: move_uploaded_file
//也可以用函数:copy
move_uploaded_file($_FILES[’photo’][’tmp_name’], $target_path); 
echo "Upload result:"; 
if(file_exists($target_path)) { 
 if($_SERVER["OS"]!="Windows_NT"){
  @chmod($target_path,0604);
 }
 echo ’Succeed!
[代码]PHP上传图片简单实现_PHP教程’; 
} else { 
 echo ’Failed!’; 

exit; 

?> 

Registration

 
(做为现在的主流开发语言)?action=upfile" method="post" name="UForm" enctype="multipart/form-data"> 
 
Your information 
     
  • Your Phot
  •  
 
 
 
 
 

技术交流 永无止境

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/509156.htmlTechArticle以下程序使用 move_uploaded_file函数上传图片到程序目录中,图片以temp_为前缀。 以下是代码片段: html head titlephp (做为现在的主流开发语言...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn