FileUpload控件是将附件下载到服务器端的磁盘上吗?如何通过访问服务器端的磁盘,打开和下载附件?我是新手,想问一下一般上传的附件是存在哪里,有从哪里下载?整个流程是怎么样的?请大家帮忙,谢谢!

解决方案 »

  1.   

    IE8,下载直接指向、下载的文件PDF就直接在IE中打开了。
    直接打开和浏览器有关。
      

  2.   

    上传的附件可存在数据库中,也可存在目录下
    以 下代码为从数据库中导出数据的程序,可参考:
    If Not oRpt Is Nothing Then
                Dim exptype As ExportFormatType
                Dim cttype As String
                Dim stm As Stream
                Dim fname As String = "fname"
                Dim fext As String
                Select Case ddlfiletype.SelectedIndex
                    ' case 0: 
                    ' exptype=ExportFormatType.Excel;
                    ' cttype="application/msexcel";
                    ' fext=".xls";
                    ' break;
                    '             Case 0
                        exptype = ExportFormatType.PortableDocFormat
                        cttype = "application/octet-stream"
                        fext = ".pdf"
                        Exit Select
                    Case 1
                        exptype = ExportFormatType.WordForWindows
                        cttype = "application/msword"
                        fext = ".doc"
                        Exit Select
                    Case 2
                        exptype = ExportFormatType.Excel
                        cttype = "application/msexcel"
                        fext = ".xls"
                        Exit Select
                    Case Else
                        exptype = ExportFormatType.RichText
                        cttype = "text/plain"
                        fext = ".rtf"
                        Exit Select
                End Select
                fname = fname & fext            stm = oRpt.ExportToStream(exptype)
                ' If Not (InlineAssignHelper(stm, oRpt.ExportToStream(exptype))) Is Nothing Then
                If Not stm Is System.DBNull.Value Then  '!!!###
                    Dim FileSize As Long                FileSize = stm.Length                Dim Buffer As Byte() = New Byte(CInt(FileSize) - 1) {}
                    stm.Read(Buffer, 0, CInt(FileSize))
                    stm.Close()
                    ''常见文件的MIME类型
                    ''GIF文件  "image/gif"
                    ''BMP文件 "image/bmp"
                    ''JPG文件 "image/jpeg"
                    ''zip文件 "application/x-zip-compressed"
                    ''DOC文件 "application/msword"
                    ''文本文件 "text/plain"
                    ''HTML文件 "text/html"
                    ''一般文件 "application/octet-stream"
                    '
                    '
                    '    '读取数据库中保存的内容
                    Response.Clear()
                    Response.Expires = 0
                    Response.Buffer = True
                    Response.ContentType = cttype
                    Response.AddHeader("Content-Length", FileSize.ToString())
                    Response.AddHeader("Content-Disposition", "attachment;filename=" & fname)
                    Response.BinaryWrite(Buffer)
                    Response.Flush()
                    Response.Close()
                Else
                    lblstatus.Text = "导出失败!"
                End If
            Else
                lblstatus.Text = "没有符合条件的数据!"
            End If 
      

  3.   

    打开WORD等等使用编辑器
    如http://www.codeproject.com/KB/office/WordInDotnet.aspx
    http://www.itwriting.com/htmleditor/index.php
      

  4.   

    要求打开excel文件但是不能进行编辑,应该怎么实现呢?
      

  5.   

    是类似百度文库的功能吗?需要将word,excel,pdf等转换为swf文件,用FlashPaper,再用FlexPaper在前台显示