简体   繁体   中英

how can I upload a image on server side in asp.net

我有一个将照片保存到图像文件夹的网络项目(我使用FileUpload),它可以在客户端运行,但是当我在主机上上传网站后,它不再起作用了,这是我的代码

FileUpload1.SaveAs(Server.MapPath("~/Image/") + FileUpload1.FileName.ToString());

Its probably write permission issues for your Image folder ,Got to your server C-Panel and give necessary permissions to the folder required.

For more on permissions see this http://technet.microsoft.com/en-us/library/bb727008.aspx

Without knowing the exception, the most likely problems are

  1. Permissions -- as others have stated. You need to look up the username of your application pool and grant that user appropriate permissions to your image subfolder
  2. Does the image subfolder even exist?
  3. File size exceeds server limits. For more information on this see this post:

Recommendations on Max File Upload Size in IIS

请检查您是否应授予Image文件夹的写权限。

check below code :

FileUpload1.SaveAs(Server.MapPath(@"Image/") + FileUpload1.FileName.ToString());

i think this will work. Please let me know.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM