我怎样才能使一个文件上传,到另一个aspx文件? [英] How can i make a file upload, to another aspx file?

查看:153
本文介绍了我怎样才能使一个文件上传,到另一个aspx文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗯,我在DOMAIN1工作。我需要上传文件到域2。在我DOMAIN1 ASPX我有(外主):

 < D​​IV ID =divCurriculo>
    <形式ID =frmCurricENCTYPE =多部分/表单数据行动=htt​​p://reports.programacontactosonae.com/uploadcv.aspx方法=邮报>
        <输入类型=隐藏名称=用户id值=284/>
    <表>
        &其中; TR>

            < TD类=第一>
                <标签>Currículo< /标签>
            < / TD>
            < TD>
                <输入类型=文件ID =filecv的风格=显示:inline-block的; />
                <输入类型=提交值=投递的风格=宽度:70px;显示:inline-block的; />
            < / TD>
        &其中; TR>
    < /表>

    < /形式GT;
< / DIV>
 

所以,我需要什么在我的接收文件了域得到文件?这是我有:

 保护无效的Page_Load(对象发件人,EventArgs的)
{
      字符串userid =的Request.Form [用户id];
      回复于(用户ID +< BR />中); //我赶上,成功,在hiddenfield价值

      HttpPostedFile文件= Request.Files [0]; //这里我得到一个错误导致它无法找到任何文件
      回复于(file.ToString());
}
 

解决方案

我希望这件事情这样简单,但尝试添加 ENCTYPE =的multipart / form-data的表格标签:

 <形式的行动=www.domain2.com/upload.aspx方法=邮报是enctype =的multipart / form-data的>
   <输入类型=隐伏ID =用户id值=12345/>
   <输入类型=文件ID =curriculo/>
   <输入类型=提交ID =提交/>
< /形式GT;
 

well, i'm working in domain1. I need to upload a file to domain2. in my aspx in domain1 i have (outside the main ):

<div id="divCurriculo">
    <form id="frmCurric" enctype="multipart/form-data" action="http://reports.programacontactosonae.com/uploadcv.aspx" method="post">
        <input type="hidden" name="userid" value="284" />
    <table>
        <tr>

            <td class="first">
                <label>Currículo</label>
            </td>
            <td>
                <input type="file" id="filecv" style="display:inline-block;" />
                <input type="submit" value="Enviar" style="width:70px;display:inline-block;" />
            </td>       
        <tr>            
    </table>

    </form>
</div>

So, what do i need in my receiving file in domain2 to get the file? This is what i have:

protected void Page_Load(object sender, EventArgs e)
{
      string userid = Request.Form["userid"];
      Response.Write(userid + "<br />"); // i catch, successfully, the value in the hiddenfield

      HttpPostedFile file = Request.Files[0];//here i get an error cause it can't find any file
      Response.Write(file.ToString());            
}

解决方案

Hopefully it's something this simple, but try adding enctype="multipart/form-data" to your form tag:

<form action="www.domain2.com/upload.aspx" method="post" enctype="multipart/form-data">
   <input type="hiden" id="userid" value="12345" />
   <input type="file" id="curriculo" />
   <input type="submit" id="submit"/>
</form>

这篇关于我怎样才能使一个文件上传,到另一个aspx文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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