文件上传从子域主域文件夹 [英] FileUpload from Subdomain to Folder of Main Domain

查看:162
本文介绍了文件上传从子域主域文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

目前的code是:

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

我曾尝试:

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

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

更新01

我也试过:

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

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

更新02

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

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

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

  response.TransmitFile(C:/Inetpub/vhosts/domain.com/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 = "http://domain.com/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.com/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.com/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);

这篇关于文件上传从子域主域文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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