文件上传从子域主域文件夹

编程入门 行业动态 更新时间:2024-10-21 11:53:50
本文介绍了文件上传从子域主域文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想荒谬的搜索,真的不知道该怎么寻找。

我不到一个新手在程序设计(平面设计师,知道太多),是有可能有一个子网站上传文件到父网站。

目前的code是:

如果(FileUpload1.HasFile)   {     字符串webPath =〜/上传/文件/;

我曾尝试:

如果(FileUpload1.HasFile)   {     字符串webPath =htt​​p://domain/Uplo​​ads/Files/;

任何帮助和指导将AP preciated,谢谢!

更新01

我也试过:

如果(FileUpload1.HasFile)   {     字符串webPath =../../httpdocs/Uplo​​ads/Files/;

这给了以下错误:不能使用领先..退出顶级目录上面

更新02

在一些谷歌上搜索我怀疑我打电话两次了一些路径。所以,我得到这个工作,但我不能完全肯定这是多么安全的。

如果(FileUpload1.HasFile)   {     字符串sysPath =C:/Inetpub/vhosts/domain/httpdocs/Uplo​​ads/Files/;

然后再次下载,有一个单独的文件中的 Download.aspx 的,我不得不改变code如下:

response.TransmitFile(C:/Inetpub/vhosts/domain/httpdocs/Uplo​​ads/Files/+文件名);

解决方案

我已经做了这种方式:

字符串THISDIR =E:/ AjkerDealLatest /图片/优惠; System.IO.Directory.CreateDirectory(THISDIR +\\+ FolderNameHiddenField.Value); ImageName = Request.Form.GetValues​​(姓名); 字符串路径= Path.Combine(E:/ AjkerDealLatest /图片/评论/+ FolderNameHiddenField.Value,ImageName [0] +.JPG); file.SaveAs(路径);

I tried ridiculous searches and don't really know what to search.

I'm less than a novice in programming (graphic designer that knows too much), is it possible to have a subdomain website upload files to the parent website.

The current code is:

if (FileUpload1.HasFile) { string webPath = "~/Uploads/Files/";

I have tried:

if (FileUpload1.HasFile) { string webPath = "domain/Uploads/Files/";

Any help and direction would be appreciated, thanks!

Update 01

I've also tried:

if (FileUpload1.HasFile) { string webPath = "../../httpdocs/Uploads/Files/";

which gave the following error: Cannot use a leading .. to exit above the top directory.

Update 02

After some more googling I suspected that I'm calling some path twice. So I got this to work, but I'm not entirely sure how secure it is.

if (FileUpload1.HasFile) { string sysPath = "C:/Inetpub/vhosts/domain/httpdocs/Uploads/Files/";

Then for downloading again, there's a separate file Download.aspx where I had to change the code as follows

response.TransmitFile("C:/Inetpub/vhosts/domain/httpdocs/Uploads/Files/" + filename);

解决方案

I have done it this way:

string ThisDir = "E:/AjkerDealLatest/images/Deals"; System.IO.Directory.CreateDirectory(ThisDir + "\\" + FolderNameHiddenField.Value); ImageName = Request.Form.GetValues("name"); string path = Path.Combine("E:/AjkerDealLatest/images/Deals/"+ FolderNameHiddenField.Value, ImageName[0] + ".jpg"); file.SaveAs(path);

更多推荐

文件上传从子域主域文件夹

本文发布于:2023-11-09 21:07:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573436.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件夹   文件上传   从子   域主域

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!