如何在上传图像并将图像保存到服务器中的文件夹时提供文件夹路径 [英] how to give folder path when upload and save image into folder in server
本文介绍了如何在上传图像并将图像保存到服务器中的文件夹时提供文件夹路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人知道吗请回复...
我想在服务器上上传图像时将图像存储在特定的文件夹中...
我尝试了以下代码,但都返回了错误,例如找不到路径....
我的代码:
1.
Can Anyone know please reply...
i want to store image in a particular folder when i upload image in server...
i tried following codes but all are returns error like can''t find out path....
my code:
1.
string savepath = Server.MapPath("../userside/clogo/" + fileName);
uploadlogo.SaveAs(savepath);
2.
2.
string savepath = Server.MapPath("./userside/clogo/" + fileName);
uploadlogo.SaveAs(savepath);
3.
3.
string savepath = Server.MapPath("~/userside/clogo/" + fileName);
uploadlogo.SaveAs(savepath);
4.
string savepath = Server.MapPath("userside/clogo/" + fileName);
uploadlogo.SaveAs(savepath);
推荐答案
您好,请使用下面的代码
Hi, use below code
string FileName = Server.MapPath("~\\Images\\Item.xls");
尝试这个
try this
string ServerSavePath = Server.MapPath("~/Upload");
string path = Path.Combine(ServerSavePath, fileName);
尝试一下
Try this
string despath = HttpContext.Current.Server.MapPath("~/Upload/clogo/" + filePathtoSave);
这篇关于如何在上传图像并将图像保存到服务器中的文件夹时提供文件夹路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文