在网格视图中上传文件 [英] file uploading in grid view

查看:98
本文介绍了在网格视图中上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
我正在使用网格视图编辑模板来上传文件
我将路径存储在数据库中,并将图像存储在本地文件夹"images"中
我编写以下代码将图像保存在本地文件夹中.

hi
i am using grid view edit template for file uploading
i am storing path in database and images in local folder "images"
i write the following code to save image in local folder.

string FileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
                  FileUpload1.SaveAs(Server.MapPath("images/" + FileName));






和网格视图中的代码






and code in grid viewis

<asp:TemplateField HeaderText="Image">
                    <ItemTemplate>
                       <asp:Image Width="100px" Height="100px" ImageUrl='<%# Eval("Photo") %>' runat="server" ID="image" />
                     </ItemTemplate>
                    <EditItemTemplate>
                       <asp:FileUpload ID="FileUpload1" runat="server" />
                    </EditItemTemplate>
                </asp:TemplateField>




如果我浏览了图像,则更新时效果很好
反之则显示错误


System.IO.DirectoryNotFoundException:找不到路径"D:\ EmsApp \ EmsApp \ EmsUI \ images \"的一部分.




it is working well when i updating if image is browsed
other wise it shows error


System.IO.DirectoryNotFoundException: Could not find a part of the path ''D:\EmsApp\EmsApp\EmsUI\images\''.

<big><big></big><big>i think that this can be solved by seeting path to image''s path 
how can i set this.</big></big>







请任何人帮助我.


谢谢







please any body help me.


thank you

推荐答案

它看起来像是路径引用的问题.尝试使用此技巧:解析多文件夹WebSite中的路径 [ ^ ]

确保正确引用了路径,并且错误应该消失了.
It looks like an issue of path reference. Try using this tip: Resolving Paths in a Multi-Folder WebSite[^]

Make sure the path is correctly referred and the error should go away.


这篇关于在网格视图中上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆