Broadband
Dial-Up
Email
Hosting
Wireless
Security
Useful Tools
Quick Reference
Contact Us
Customer Portal
Site Search

Zen Internet Support Forum

Welcome to the Zen Internet community support forums.

Before posting we recommend you search our
extensive Knowledge Base or the forum archives
as an answer to your query may already be available.

Welcome to Zen Internet Support Forum Sign in | Join | Help
in
Forums Forum Rules

Link to file if it has been uploaded

Last post 12-07-2006, 8:53 AM by johncarr. 4 replies.
Sort Posts: Previous Next
  •  06-07-2006, 4:08 PM 18613

    Link to file if it has been uploaded

    I would like to create a webpage for the year ahead, which has links to PDF files that are uploaded weekly.

    week01.pdf
    week02.pdf
    ..
    ..
    week51.pdf
    etc.


    I would like the page to either:-

    Display all the links (e.g. Week01 - Week51) and if someone picks a link which hasn't got the relative PDF file uploaded, they get a message box stating "Not Uploaded yet" instead of getting "404 The page cannot be found"

    or

    Not to display the link until the PDF file is present.

    Thanks
    John

  •  07-07-2006, 11:00 PM 18660 in reply to 18613

    Re: Link to file if it has been uploaded

    Just do it like you have?

    Upload the list for the year and when you upload that weeks0?.pdf file link it with that weeks pdf all other are not linked so if anybody puts mouse over nothing happens as week01.pdf should look more like this lol

    week01.pdf
    week02.pdf
    week03.pdf
    week04.pdf
    week05.pdf
    week06.pdf
    ..
    ..
    week51.pdf
    etc.

  •  08-07-2006, 2:19 PM 18672 in reply to 18660

    Re: Link to file if it has been uploaded

    It should be perfectly easy to write a server side script to do this too.

    The following is an example of how you might achieve this with ASP.NET - I'm sure its perfectly doable in PHP too.


    <%@ page language = "VB" %>
    <%@ Import namespace="System.IO" %>
    <%@ Import namespace="System.Data"%>

    <script runat="server">
       Sub page_load()
          '###### Declare the objects to be used ########
          Dim strFileName as string
          Dim objDT as datatable
          Dim objDC as datacolumn
          Dim objDR as datarow

         '###### Set up the Datatable which will contain a list of the filenames in our directory ######
          objDT = New datatable("Filelist")
          objDC = New datacolumn("filename", Gettype(string))
          objDT.Columns.Add(objDC)

         '###### For every file in the directory "pdf_directory", ######
         '###### Add a row to the datatable containing its filename ######
          For each strFileName in Directory.GetFiles(server.mappath("pdf_directory\"))
              objDR = objDT.NewRow()
              objDR.Item("filename") = Path.getFileName(strFileName)
              objDT.Rows.Add(objDR)
          Next str_newimagepath

          '###### Bind the datatable of filenames to the Repeater which lists them ######
          rpMyFileList.DataSource = objDT
          rpMyFileList.DataBind()
       End Sub
    </script>

    <html>
    <head>
    <title>List of uploaded Files</title>
    </head>

    <body>
    <asp:Repeater id="rpMyFileList" runat="server">
       <ItemTemplate>
          <a href='pdf_directory/<%# Container.DataItem("filename") %>'><%# Container.DataItem("filename") %></a><br>
       </ItemTemplate>
    </asp:Repeater>

    </body>
    </html>


    Kindest regards,

    James Sweet
    http://www.zen.co.uk
  •  08-07-2006, 2:27 PM 18673 in reply to 18672

    Re: Link to file if it has been uploaded

    Or of course for a method that involves no code whatsoever, but won't look very pretty....

    Just upload all your pdf files to a directory as normal, but make sure that directory browsing is enabled for that directory (on the Zen free space this is enabled by default).
    Create a link to that directory from your main site.
    Make sure there are no index pages in that directory

    Anyone browsing to the directory will then see a list of all the PDF files in the directory, and can just download them at will.



    EDIT -
    Actually just checked, and as usual there IS a way to make it look pretty
    Just include a file called HEADER (or header.html)  which contains HTML you want to display before the directory list, and a file called README (or readme.html) which contains HTML you want to display after the directory list.

    If you are on a RaQ or cPanel account then you should place a .htaccess file in the directory containing the lines:
    Options Indexes
    IndexOptions -FancyIndexing
    IndexIgnore HEADER README .htaccess

    Have a read of http://underscorebleach.net/jotsheet/2004/01/apache-indexes-101 for more info

    Kindest regards,

    James Sweet
    http://www.zen.co.uk
  •  12-07-2006, 8:53 AM 18806 in reply to 18673

    Re: Link to file if it has been uploaded

    James,

    Thanks for the reply, I've had a look at the link and I think this is my best option.

    Thanks again

    John

View as RSS news feed in XML