上传后无法在文件夹中看到图像 [英] Unable to see image in folder after upload

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

问题描述

您好,



我正在使用带有母版页面的webform ...因为我已经使用了fileupload和上传按钮..

当我浏览图片并上传...图片未保存在文件夹中...

这个帖子回来的问题或代码pblm ???

或者我可以不用使用fileupload ???



谢谢



  protected   void  RadBtn_Upload_Click( object  sender,EventArgs e)
{
尝试
{

string filename = System.IO.Path.GetFileName(FileUpload.PostedFile.FileName);
FileUpload.SaveAs(Server.MapPath( img / + filename));


}
catch (例外情况)
{

< span class =code-keyword> throw ex;

}

解决方案

我认为...浏览你的页面中调用的文件回发事件之后为什么你的fileupload控件丢失了它的文件名...



所以你必须检查..

并且在上传文件之前总是检查Hasfile条件在服务器上..



例如:

  if (FileUpload.HasFile)
{
string filename = System.IO.Path.GetFileName(FileUpload.PostedFile.FileName);
FileUpload.SaveAs(Server.MapPath( img / + filename));
}







谢谢

AARIF SHAIKH


Hello,

Im using webform with masterpage...in that i have taken fileupload and upload button..
when i browse image and upload...image is not saving in the folder...
IS this post back problem or code pblm???
or can i do this without using fileupload???

Thank you

protected void RadBtn_Upload_Click(object sender, EventArgs e)
     {
         try
         {

   string filename=System.IO.Path.GetFileName(FileUpload.PostedFile.FileName);
            FileUpload.SaveAs(Server.MapPath("img/" + filename));


         }
         catch (Exception ex)
         {

             throw ex;

         }

解决方案

I think... after browse your file postback event called in your page that why your fileupload control lost it file name ...

So you have to check that..
and always check Hasfile condition before uploading file on server..

For Example :

if (FileUpload.HasFile)
      { 
           string filename=System.IO.Path.GetFileName(FileUpload.PostedFile.FileName);
            FileUpload.SaveAs(Server.MapPath("img/" + filename)); 
      }




Thanks
AARIF SHAIKH


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

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