#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2008
    Posts
    6
    Rep Power
    0

    FTP to HTTP location redirect


    Is it possible to redirect from ftp to http?
    for example browser loads
    <img src="ftp://anon@ftp.server.net/picture.jpg">
    but ftp.server.net does not have this file and redirects browser to http location or another ftp location?
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Location
    Pennsylvania, USA
    Posts
    35
    Rep Power
    2
    You could try the PHP ftp_get() function first. If it returns false, then, you could try alternative options. In all cases, you could
    save the image locally before displaying it depending on your needs:

    Code:
    $image = file_get_contents('anonymous@ftp.server.net');
    file_put_contents('thefile.jpg', $image);
    In your HTML tag, you would then reference:
    Code:
    <img src="thefile.jpg">
  4. #3
  5. No Profile Picture
    Dazed&Confused
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Location
    Tempe, AZ
    Posts
    506
    Rep Power
    128
    Originally Posted by eurusd
    Is it possible to redirect from ftp to http?
    for example browser loads
    <img src="ftp://anon@ftp.server.net/picture.jpg">
    but ftp.server.net does not have this file and redirects browser to http location or another ftp location?
    In the way you're looking for, not really.

    "ftp" is a completely different protocol than "http" and it's really just because browsers are nice that they even know what to do with the "ftp" protocol. Behind the scenes the FTP protocol will be run by a completely different service than the one providing you HTTP protocol and it wouldn't even be able to tell that the request is coming from a web browser vs. a standalone FTP client.

    Note, however, that the above is based your typical FTP/HTTP servers. In theory there might be FTP services out there, or one you could write yourself, that COULD detect that you're coming from a browser, but I have no idea if the browser would accept an HTTP redirect header when dealing with what it THINKS is the FTP protocol. You're kind of talking in two different languages at that point.
    LinkedIn: Dave Mittner
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    27
    Rep Power
    0
    Hope this helps you.

    You need to look into setting up a HTTP server which supports WebDAV. I recommend Nginx or Apache. I believe WebDAV supports the FTP protocol so although you won't be able to redirect the user you will be able to serve them a file through a HTTP server rather than an FTP server.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    3
    Rep Power
    0
    I think FTP to HTTP location not redirect, because there is no "redirect to a different protocol" command an FTP server can send. (At least, not one that any standard FTP client would understand.)

IMN logo majestic logo threadwatch logo seochat tools logo