前台:
<div>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server"
Text="Button" onclick="Button1_Click" />
<asp:Image ID="Image1" runat="server" />
</div>
后台:
protected void Button1_Click(object sender, EventArgs e)
{
FileUpload1SaveAs(ServerMapPath("img/"+FileUpload1FileName));//上传
Image1ImageUrl = "~/img/" + FileUpload1FileName;//路径(将这个数据保存到数据库就可以了。img为项目里一个文件夹的名称)
}<php
$type=$_FILES['filephoto']['type'];
if($type=='image/gif'|| $type=='image/jpeg'||$type=='image/pjpeg')
{
if($_FILES['filephoto']['size']<210241024)
{
$aa=substr($_FILES['filephoto']['name'],strpos($_FILES['filephoto']['name'],''));//类型名 如 png
$photo=date("yndhis")rand(10000,99999)$aa;//名字
move_uploaded_file( $_FILES['filephoto']['tmp_name'] , 'photo/'$photo );//上传指定文件夹
}//$image=文件夹名/名 添加数据库
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)