部署后无法将映像上传到远程服务器 [英] Could not upload image to remote server after deploying

查看:82
本文介绍了部署后无法将映像上传到远程服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要将图像上传到远程服务器。代码在我的localhost中工作正常。

所以我在IIS中部署了我的应用程序,但现在我无法上传任何图像。



当我单击按钮时,页面将回发到服务器,但没有响应。请帮我解决这个问题。



这是我的代码



Hi,
I need to upload an image to remote server . The code is working fine in my localhost.
So i deployed my app in IIS , but now i am not able upload any image.

When i click the Button, The Page is getting post back to the server , but no response . Please help me to solve this issue.

Here is my code

try
   {
   string filename = Path.GetFileName(FileUploadimage1.PostedFile.FileName);
   string filename2 = Path.GetFileName(FileUploadimage2.PostedFile.FileName);

   FileUploadimage1.SaveAs(Server.MapPath("~/ProductImages/" + filename));
   FileUploadimage2.SaveAs(Server.MapPath("~/ProductImages/" + filename2));
                           
   con.Open();
   string filepaths2 = "~/ProductImages/" + filename2;

   string filepaths = "~/ProductImages/" + filename;
   SqlCommand cmd = new SqlCommand("Insert into ProductTable values('" + txtid.Text + "','" + txtdetaileddescription.Text + "','" + txtdescription.Text + "','" + txtprice.Text + "','" + ddlcategory.SelectedItem.Text + "','" + filepaths + "','" + filepaths2 + "','"+filename2+"','"+filename+"','"+Convert.ToInt64(txtactualprice.Text)+"')", con);
               

    cmd.ExecuteNonQuery();
          

   Response.Write("<script>alert('added')</script>");
            }
            catch
            {
Response.Write("<script>alert('Could not be added')</script>");
            }
            finally
            {
                con.Close();
     }

推荐答案

检查IIS的权限。 IIS是否有权上传到服务器。现在,由于您的解决方案在IIS下运行,IIS应该有很多权利上传文件。



只需检查一下这可能有用。
Check with the right to IIS. does IIS have right to upload to the server. Now since your solution running under the IIS, IIS should have that much right to upload the file.

Just check may this help.


这篇关于部署后无法将映像上传到远程服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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