上传照片 if ($upload){ //如果点击"上传",则执行此php代码部分
if ($picurl=="none"){
echo "你没有上传任何文件.";
exit; //如果没有上传文件,则退出程序
}
$v=opendir("image");
if ($v==0)
{ mkdir("image"); //若目录不存在,则新建一个
$v=opendir("image"); //取得目录handle
}
$up=copy("$picurl","image/$picurl_name"); //关键一步,将临时文件复制到image目录下
if($up==1)
{
//文件操作
$fp=fopen("photo.txt","a");//打开文件,以添加方式写入留言
//初始化写入内容
$mydate=date("Y年m月d日 h:i A");
$photonote=nl2br($photonote);//将换行字元转成
。
$text="照片名:
$picurl_name 照片大小:$picurl_size byte
照片说明:
$photonote 上传人: $user($mydate)
";
//写入内容
fwrite($fp,$text,strlen($text)); //strlin计算$text的字串长度
fclose($fp);
echo "文件上传成功!
";
unlink ($picurl); //从临时文件夹中删除档案$picurl
closedir ($v); //关闭目录handle
}
else
{echo "文件上传失败."; exit;} //若上传失败,则退出程序
}
?>
所有照片 |
//显示以往上传照片信息 readfile ("photo.txt"); ?> |
上传照片 ="multipart/form-data" name="UL"> Action--> "image/x-png,image/gif,image/jpeg"> photonote" cols="50" rows="5"> maxlength = "10"> "Reset" value="Rewrite"> "javascript:history.back()"> Return |
< ;/BODY>
[The copyright of this article is jointly owned by the author and Oso.com. If you need to reprint, please indicate the author and source]
http://www.bkjia.com/PHPjc/316709.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/316709.html
TechArticle
!--Upload photo example upimage.php Function: Upload photos, display the uploader, upload time, picture name, Image size, image description. Note: 1. Some homepage spaces may not support...
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