SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question about downloading files that were uploaded

    I have a question. If a user uploads a file (an image called myprettypony.bmp, let's say) to my site, which gets placed in the public/data directory, how do I go about making it so that people can write html like, "[fakehtmlbracket]img src="(AechTeeTeePee)IPADDRESSHERE:3000/public/data/myprettypony.bmp"[fakehtmlendbracket]"? Currently I get a routing error, because no route exists for public/data. How could I make this work so that the link goes through and the image is displayed on the page that the user is linking from? It may just be an idiotically simple route, but...

    Hmm, Sitepoint doesn't allow html brackets for me! (yet.)

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2008
    Location
    England
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is your public/data directory within your website directory, e.g htdocs? If so, and you have a dir structure like:

    htdocs/public/data/

    then your example would work.

    If the public/data directory lies outside of the website directory then you're not going to be able to reference it in a URL. If you have access, you could create a shortcut/link inside you website directory to the public/data directory - depends on the OS of the webserver.

    If you're still having problems, could you let us know your directory structure and I might be able to help further.

    P.S. To display html tags in a post, select your html and click the # icon in the editor to mark it as code.

  3. #3
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    shovell (my application) ->
         app
         config
         data
         db
         doc
         lib
         log
         public ->
              data ->
                   Files I'm trying to access
         Rakefile
         README
         script
         test
         tmp
         vendor
    I run Ubuntu Linux.

    I'm trying to access file "logo_Ubuntu.png" in my "public/data" directory, so I type:
    Code:
    (H)(T)(T)(P)://MY_INTERNAL_IP:3000/public/data/logo_Ubuntu.png
    Then I get a routing error. Am I trying to access the file incorrectly?

    Now I'm thinking I may have screwed something up in the routes.rb file, so...

    Code:
    ActionController::Routing::Routes.draw do |map|
      map.connect '', :controller => "story"
      map.connect ':controller/service.wsdl', :action => 'wsdl'
      map.story 'story/show/:permalink',
        :controller => 'story',
        :action => 'show'  
      map.connect ':controller/:action/:id'
    end
    Yup, it's Shovell again.

    THE HUMILIATION! IT HURTS!

  4. #4
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Remove "public".

    MY_INTERNAL_IP:3000/data/logo_Ubuntu.png
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  5. #5
    SitePoint Member
    Join Date
    Jul 2008
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ...

    Wow, I'm a freakin' idiot.

    That worked. I remember that I was going to do that in the first place, but I forgot.

    Wow. Every thread I make ends in my stupidity.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •