当前位置:首页 » 文件管理 » 图片上传控件

图片上传控件

发布时间: 2022-01-08 11:56:11

A. ASP.NET上传控件上传图片

要吗你就是随机生成字符串,要吗就是以时间为名字,精确到毫秒就应该差不多了啊

B. 使用FileUpload控件,上传图片到images下的upload文件夹中,代码要添加什么才能上传

protected void Button1_Click(object sender, EventArgs e)
{
string cat = Server.MapPath(@"images/upload/");
if (System.IO.Directory.Exists(cat) == false)
{
System.IO.Directory.CreateDirectory(cat);
}
if (FileUpload1.HasFile == true)
{
FileUpload1.SaveAs(cat + FileUpload1.FileName);
Response.Write("<script> alert('上传成功!')</script>");
Label1.Text = "images/upload/" + FileUpload1.FileName.ToString();
}

}

C. 用FileUpload控件怎么实现多图片上传

单存的FileUpload控件无法实现多图片上传!要做成那种多选效果一般现在用 as编写的flash控件!效果相当不错!!你可以在网上找找

D. 上传图片控件的问题

刚了你的代码,运行了一下,没有发现你说的问题,点击浏览之后,文本框中会保留路径,在点击div后文本框中的值会改变,但不会情空文本框,敢问你用的IE版本是那个,是否是因为存在浏览器兼容性问题

E. 怎么把图片路径赋到上传控件FileUpload中

好像不太好找
一般都用fileupload
如果特殊需要
就自定义呗

F. ext js 上传图片控件

在服务端判断了,假设你的客户端控件 name = ”photo-path“
服务端可以写成以下:

HttpPostedFile postedFile = Request.Files["photo-path"];//获取上传信息对象
string filename = postedFile.FileName;//获取上传的文件路径
string sExtension = filename.Substring(filename.LastIndexOf('.'));//获取拓展名

然后就可以判断是否正确了,但是通过扩展名判断文件类型比较不靠谱了,因为扩展名是可以变更的。

G. 急求一个图片上传控件

谢谢楼上的回帖,但是你写的这个功能,我可以实现的,关键就是怎么可以在预览中,有一个框,可以调整这个框的大小,只要被这个框选中的区域,点一下确认后,就可以生产一个选中区域的图片,就是校内上传头像的那个控件或者是方法。在这里我还是要感谢一下楼上的代码。谢谢你了啊!!在线等,我很急的啊!!!

H. Dev控件的ASPxUploadControl怎么实现图片上传

MaxFileSizeErrorText="图片大小不得超过2M!" ="不支持的图片格式!">
</ValidationSettings>
</dx:ASPxUploadControl>js://上传控件赋值给图片控件显示
function Uploader_OnFileUploadComplete(args) {
if (args.isValid) {
var imgSrc = decodeURI(args.callbackData);
ASPxClientImage.Cast('previewImage').SetImageUrl(imgSrc);
ASPxClientHiddenField.Cast("HiddenIds").Set("ImageUrl", imgSrc);}}function BeginUpload() {
var uploader = ASPxClientUploadControl.Cast('uploader');
var reg = /[@#\$%\^&\*]+/g;
if (uploader.GetText(0) != "") {
if (!reg.test(uploader.GetText(0))) {
uploader.Upload();} else {alert("文件名不能含有非法字符!");
uploader.ClearText();}}}后台://文件上传protected void FileToUpload_FileUploadComplete(object sender, DevExpress.Web.ASPxUploadControl.FileUploadCompleteEventArgs e){//删除旧相片
//保存新相片
e.CallbackData = SavePostedFile(e.UploadedFile);}private string SavePostedFile(UploadedFile uploadFile){//设置图片地址
const string UploadDirectory = "../../UploadFile/GuestPhoto/";
//得到服务器相片地址

I. 使用FileUpLoad上传图片 并且上传时把图片显示到Image控件中 请问你有具体的代码吗,能否发过来看看

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{

//检查上传文件的格式是否有效
if(this.FileUpload1.PostedFile.ContentType.ToLower().IndexOf("image") < 0)
{
Response.Write("上传图片格式无效!");
return;
}
//生成原图
Byte[] oFileByte = new byte[this.FileUpload1.PostedFile.ContentLength];
System.IO.Stream oStream = this.FileUpload1.PostedFile.InputStream;
System.Drawing.Image oImage = System.Drawing.Image.FromStream(oStream);
int oWidth = oImage.Width; //原图宽度
int oHeight = oImage.Height; //原图高度
int tWidth = 100; //设置缩略图初始宽度
int tHeight = 100; //设置缩略图初始高度
//按比例计算出缩略图的宽度和高度
if(oWidth >= oHeight)
{
tHeight = (int)Math.Floor(Convert.ToDouble(oHeight) * (Convert.ToDouble(tWidth)
/ Convert.ToDouble(oWidth)));
}
else
{
tWidth = (int)Math.Floor(Convert.ToDouble(oWidth) * (Convert.ToDouble(tHeight)
/ Convert.ToDouble(oHeight)));
}

//生成缩略原图
Bitmap tImage = new Bitmap(tWidth,tHeight);
Graphics g = Graphics.FromImage(tImage);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
//设置高质量插值法
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
//设置高质量,低速度呈现平滑程度
g.Clear(Color.Transparent); //清空画布并以透明背景色填充
g.DrawImage(oImage,new Rectangle(0,0,tWidth,tHeight),
new Rectangle(0,0,oWidth,oHeight),GraphicsUnit.Pixel);
string oFullName = Server.MapPath(".") + "/" + "o" +
DateTime.Now.ToShortDateString().Replace("-","") + DateTime.Now.Hour.ToString()
+ DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString()
+ DateTime.Now.Millisecond.ToString() + ".jpg"; //保存原图的物理路径
string tFullName = Server.MapPath(".") + "/" + "t" +
DateTime.Now.ToShortDateString().Replace("-","") + DateTime.Now.Hour.ToString()
+ DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString()
+ DateTime.Now.Millisecond.ToString() + ".jpg"; //保存缩略图的物理路径
try
{
//以JPG格式保存图片
oImage.Save(oFullName,System.Drawing.Imaging.ImageFormat.Jpeg);
tImage.Save(tFullName,System.Drawing.Imaging.ImageFormat.Jpeg);
}
catch(Exception ex)
{
throw ex;
}
finally
{
//释放资源
oImage.Dispose();
g.Dispose();
tImage.Dispose();
}
}
}using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{

//检查上传文件的格式是否有效
if(this.FileUpload1.PostedFile.ContentType.ToLower().IndexOf("image") < 0)
{
Response.Write("上传图片格式无效!");
return;
}
//生成原图
Byte[] oFileByte = new byte[this.FileUpload1.PostedFile.ContentLength];
System.IO.Stream oStream = this.FileUpload1.PostedFile.InputStream;
System.Drawing.Image oImage = System.Drawing.Image.FromStream(oStream);
int oWidth = oImage.Width; //原图宽度
int oHeight = oImage.Height; //原图高度
int tWidth = 100; //设置缩略图初始宽度
int tHeight = 100; //设置缩略图初始高度
//按比例计算出缩略图的宽度和高度
if(oWidth >= oHeight)
{
tHeight = (int)Math.Floor(Convert.ToDouble(oHeight) * (Convert.ToDouble(tWidth)
/ Convert.ToDouble(oWidth)));
}
else
{
tWidth = (int)Math.Floor(Convert.ToDouble(oWidth) * (Convert.ToDouble(tHeight)
/ Convert.ToDouble(oHeight)));
}

//生成缩略原图
Bitmap tImage = new Bitmap(tWidth,tHeight);
Graphics g = Graphics.FromImage(tImage);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
//设置高质量插值法
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
//设置高质量,低速度呈现平滑程度
g.Clear(Color.Transparent); //清空画布并以透明背景色填充
g.DrawImage(oImage,new Rectangle(0,0,tWidth,tHeight),
new Rectangle(0,0,oWidth,oHeight),GraphicsUnit.Pixel);
string oFullName = Server.MapPath(".") + "/" + "o" +
DateTime.Now.ToShortDateString().Replace("-","") + DateTime.Now.Hour.ToString()
+ DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString()
+ DateTime.Now.Millisecond.ToString() + ".jpg"; //保存原图的物理路径
string tFullName = Server.MapPath(".") + "/" + "t" +
DateTime.Now.ToShortDateString().Replace("-","") + DateTime.Now.Hour.ToString()
+ DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString()
+ DateTime.Now.Millisecond.ToString() + ".jpg"; //保存缩略图的物理路径
try
{
//以JPG格式保存图片
oImage.Save(oFullName,System.Drawing.Imaging.ImageFormat.Jpeg);
tImage.Save(tFullName,System.Drawing.Imaging.ImageFormat.Jpeg);
}
catch(Exception ex)
{
throw ex;
}
finally
{
//释放资源
oImage.Dispose();
g.Dispose();
tImage.Dispose();
}
}
}

热点内容
单片机android 发布:2024-09-20 09:07:24 浏览:765
如何提高三星a7安卓版本 发布:2024-09-20 08:42:35 浏览:664
如何更换服务器网站 发布:2024-09-20 08:42:34 浏览:311
子弹算法 发布:2024-09-20 08:41:55 浏览:289
手机版网易我的世界服务器推荐 发布:2024-09-20 08:41:52 浏览:817
安卓x7怎么边打游戏边看视频 发布:2024-09-20 08:41:52 浏览:162
sql数据库安全 发布:2024-09-20 08:31:32 浏览:94
苹果连接id服务器出错是怎么回事 发布:2024-09-20 08:01:07 浏览:507
编程键是什么 发布:2024-09-20 07:52:47 浏览:658
学考密码重置要求的证件是什么 发布:2024-09-20 07:19:46 浏览:481