Looking to upload pdf and be able to view/download from browser

Discussion in 'C#' started by vicesquad26, Dec 7, 2008.

  1. #1
    Hey Guys,

    Looking for a solution (preferably free) for uploading and viewing files (pdf mainly). Is there a component or behaviour that I can download for dreamweaver that will allow me to setup an upload form which uploads to the database and then subsequently displays on a page within my website.

    Or is there some snippets of code which will do this?

    Thanks very much in advance! :D

    Mr Desperate
     
    vicesquad26, Dec 7, 2008 IP
  2. vihutuo

    vihutuo Well-Known Member

    Messages:
    1,511
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    180
    #2
    I think you can upload pdf files normally like other files. No special code will be required to upload pdf files... Also displaying pdf files is usually done by the browser so again no special code will be required to display a pdf ....
    If you want to store a pdf file in database, you can store the file in the file sysytem and then store the path to the file in the database...
     
    vihutuo, Dec 7, 2008 IP
  3. vicesquad26

    vicesquad26 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for your reply mate :)

    I am aware of this, but I need to know how to actually do this :confused:
     
    vicesquad26, Dec 7, 2008 IP
  4. islandhopper8

    islandhopper8 Active Member

    Messages:
    100
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    73
    #4
    In ASP.net in VS you just drop the FileUpload control from the toolbox on the webpage something like this:
    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="showpdf._Default" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Untitled Page</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <asp:FileUpload ID="FileUpload1" runat="server" /><asp:Button ID="Button1" runat="server"
    Text="Button" />
    </div>
    <asp:Literal ID="Literal1" runat="server"></asp:Literal>
    </form>
    </body>
    </html>

    and in the code behind you do:

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
    If Not String.IsNullOrEmpty(Me.FileUpload1.FileName) Then
    Dim myFile As HttpPostedFile = FileUpload1.PostedFile
    Dim p As String = Server.MapPath(".")
    myFile.SaveAs(p & "\test.pdf")
    Me.Literal1.Text = "<a href=""test.pdf"">show PDF<a/>"
    End If

    End Sub

    Is this what you are looking for?
     
    islandhopper8, Dec 17, 2008 IP
  5. davejames10

    davejames10 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    if its classic asp heres a good free tool : http://asp-upload.motobit.com/

    with easy to follow examples etc..

    cheers,dave.
     
    davejames10, Jan 3, 2009 IP