使用asp.net中的fileupload控件上传文件
我想使用 asp.net 中的 FileUpload 控件上传文件,我使用以下代码来执行此操作:
string filename1 = System.IO.Path.GetFileName(FileUploadControl.FileName);
FileUploadControl.SaveAs("C:\\Users\\admin\\Desktop\\ExperimentForFolder\\" + filename1);
我也尝试过,
FileUploadControl.SaveAs(@"C:\Users\admin\Desktop\ExperimentForFolder\" + filename1);
但它仍然很糟糕。我不明白出了什么问题。你能帮我一下吗?
感谢期待
I want to upload a file using FileUpload Control in asp.net and i'm using the following code to do that:
string filename1 = System.IO.Path.GetFileName(FileUploadControl.FileName);
FileUploadControl.SaveAs("C:\\Users\\admin\\Desktop\\ExperimentForFolder\\" + filename1);
i also tried
FileUploadControl.SaveAs(@"C:\Users\admin\Desktop\ExperimentForFolder\" + filename1);
But it is still freaking out. I don't understand what is wrong. Can you please help me.
Thanks in anticipation
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么需要将文件保存到计算机的桌面上?
您的最终选择应该是使用您的应用程序文件夹。它可以像...
Why do you need to save the file to your machine's Desktop?
Your ultimate option should be to use your Application Folder. It can be done like...
您需要对存储文件的位置有权限...不要存储在服务器桌面中。
尝试开始:
这会将文件存储在与您的
.aspx
文件相同的位置,如果它有效,您可以在那里创建单独的文件夹,然后将代码更改为:You need permissions over the place you store the file into... don't store in the server desktop.
Try this for start:
This will store the file in the same place as your
.aspx
file, if it works you can then create separate folder there then change the code to: