PHP头条
热点:

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


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

以下是代码片段:


PHP上传图片简单实现 www.cncms.com.cn


if($_GET[https://www.php1.cn/detail/’actionhttps://www.php1.cn/detail/’] == https://www.php1.cn/detail/’upfilehttps://www.php1.cn/detail/’)
{
$target_path = https://www.php1.cn/detail/’temp_https://www.php1.cn/detail/’.$_FILES[https://www.php1.cn/detail/’photohttps://www.php1.cn/detail/’][https://www.php1.cn/detail/’namehttps://www.php1.cn/detail/’];
echo https://www.php1.cn/detail/’上传的临时文件:https://www.php1.cn/detail/’ .$_FILES[https://www.php1.cn/detail/’photohttps://www.php1.cn/detail/’][https://www.php1.cn/detail/’tmp_namehttps://www.php1.cn/detail/’] . https://www.php1.cn/detail/’
https://www.php1.cn/detail/’;
echo https://www.php1.cn/detail/’上传的目标文件:https://www.php1.cn/detail/’ .$target_path . https://www.php1.cn/detail/’
https://www.php1.cn/detail/’;
echo $_SERVER["SCRIPT_FILENAME"] . https://www.php1.cn/detail/’
https://www.php1.cn/detail/’;
echo $_SERVER["OS"] . https://www.php1.cn/detail/’
https://www.php1.cn/detail/’;
//测试函数: move_uploaded_file
//也可以用函数:copy
move_uploaded_file($_FILES[https://www.php1.cn/detail/’photohttps://www.php1.cn/detail/’][https://www.php1.cn/detail/’tmp_namehttps://www.php1.cn/detail/’], $target_path);
echo "Upload result:";
if(file_exists($target_path)) {
if($_SERVER["OS"]!="Windows_NT"){
 @chmod($target_path,0604);
}
echo https://www.php1.cn/detail/’Succeed!
https://www.php1.cn/detail/’;
} else {
echo https://www.php1.cn/detail/’Failed!https://www.php1.cn/detail/’;
}
exit;
}
?>

Registration




Your information

  • Your Phot






技术交流 永无止境

www.phpzy.comtrue/phpyy/49421.htmlTechArticle[代码]PHP上传图片简单实现 以下程序使用move_uploaded_file函数上传图片到程序目录中,图片以temp_为前缀。 以下是代码片段: PHP上传图片简单实现 www.cncms.com.cn if(_GET[https://www.php1.cn/deta...

相关文章

PHP之友评论

今天推荐