Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Regular Coder
    Join Date
    Jun 2007
    Location
    Los Angeles
    Posts
    545
    Thanks
    81
    Thanked 5 Times in 5 Posts

    Save As from a URL?

    Is there a way I can download a file to my local PC using a File Save As dialog but which grabs the file using a URL?

    Thanks...
    RalphF
    Business Text Messaging Services
    https://www.MobileTextingService.com

  • #2
    New Coder
    Join Date
    Aug 2003
    Location
    Derby, UK
    Posts
    97
    Thanks
    0
    Thanked 14 Times in 14 Posts
    Unclear on the question - File/Save As from what - your browser? some other application? Browser "Save As" is already saving it from whatever URL the browser is pointed at, so again, unclear what exactly you are trying to achieve that you can't by default?

  • #3
    Regular Coder
    Join Date
    Jun 2007
    Location
    Los Angeles
    Posts
    545
    Thanks
    81
    Thanked 5 Times in 5 Posts
    Yes, from a browser I want to have a File Save As dialog popup and I want to pull the file via a URL and save it to my local PC.
    RalphF
    Business Text Messaging Services
    https://www.MobileTextingService.com

  • #4
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    The question still makes no sense. If you point your browser to the URI of a file, it will already prompt you to save/open the file.

    If you want to achieve something else, explain exactly what you mean/want.

  • #5
    Regular Coder
    Join Date
    Jun 2007
    Location
    Los Angeles
    Posts
    545
    Thanks
    81
    Thanked 5 Times in 5 Posts
    >If you point your browser to the URI of a file, it will already prompt you to >save/open the file.

    How do you do this in PHP? What function?
    RalphF
    Business Text Messaging Services
    https://www.MobileTextingService.com

  • #6
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Quote Originally Posted by rfresh View Post
    >If you point your browser to the URI of a file, it will already prompt you to >save/open the file.

    How do you do this in PHP? What function?
    Do what? If you're going to speak in riddles.....

  • #7
    Regular Coder
    Join Date
    Apr 2008
    Posts
    685
    Thanks
    15
    Thanked 105 Times in 104 Posts
    I think the header() function does this for you

  • Users who have thanked Scriptet for this post:

    rfresh (07-20-2009)

  • #8
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Quote Originally Posted by Scriptet View Post
    I think the header() function does this for you
    If he's wanting to serve a file from a script link, it does. The Location, Content-type and Content-Disposition parts are the relevant ones.

  • #9
    Regular Coder
    Join Date
    Jan 2008
    Location
    Geneva, Switzerland
    Posts
    413
    Thanks
    12
    Thanked 29 Times in 29 Posts
    What is the goal? To hide the URL of the file you want users to download?
    Chuck Norris counted to infinity.
    Twice.

  • #10
    Regular Coder
    Join Date
    Jun 2007
    Location
    Los Angeles
    Posts
    545
    Thanks
    81
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by Arnaud View Post
    What is the goal? To hide the URL of the file you want users to download?
    The goal is to pull a file from a different server than the php script is running on and then save it to my local PC.
    RalphF
    Business Text Messaging Services
    https://www.MobileTextingService.com

  • #11
    Regular Coder
    Join Date
    Jan 2008
    Location
    Geneva, Switzerland
    Posts
    413
    Thanks
    12
    Thanked 29 Times in 29 Posts
    You are good at giving us a very little more info at each post...

    I don't see what special you need... what kind of file are you trying to save? What extension?

    If I have server 1 that is www.mysite.com and server 2 that is www.myothersite.com what is the problem to make a link such as the below one?
    Code:
    <a href="http://www.myothersite.com/file.txt">Download</a>
    Of course it depends what kind of file you are trying to download...
    Chuck Norris counted to infinity.
    Twice.

  • #12
    Regular Coder
    Join Date
    Jun 2007
    Location
    Los Angeles
    Posts
    545
    Thanks
    81
    Thanked 5 Times in 5 Posts
    It's a .txt file. I will try your code example. Thanks...
    RalphF
    Business Text Messaging Services
    https://www.MobileTextingService.com

  • #13
    Regular Coder
    Join Date
    Jan 2008
    Location
    Geneva, Switzerland
    Posts
    413
    Thanks
    12
    Thanked 29 Times in 29 Posts
    Well... this is not 'code'... This is a simple HTML hyperlink...
    Chuck Norris counted to infinity.
    Twice.

  • #14
    Regular Coder
    Join Date
    Jun 2007
    Location
    Los Angeles
    Posts
    545
    Thanks
    81
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by Arnaud View Post
    You are good at giving us a very little more info at each post...

    I don't see what special you need... what kind of file are you trying to save? What extension?

    If I have server 1 that is www.mysite.com and server 2 that is www.myothersite.com what is the problem to make a link such as the below one?
    Code:
    <a href="http://www.myothersite.com/file.txt">Download</a>
    Of course it depends what kind of file you are trying to download...
    Your example code just pulls the .txt content into the browser, there is no Save As dialog.

    As MattF stated, I think I need to use header()
    RalphF
    Business Text Messaging Services
    https://www.MobileTextingService.com

  • #15
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Quote Originally Posted by rfresh View Post
    Your example code just pulls the .txt content into the browser, there is no Save As dialog.

    As MattF stated, I think I need to use header()
    You'll need to use a placeholder link inplace of the direct link, which calls your script and processes the request, for this method to work.

  • Users who have thanked MattF for this post:

    rfresh (07-20-2009)


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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