Jump to content

FTP to a client drive from server


macdunn

Recommended Posts

Next topic from me -- how do we use PHP or JavaScript to transfer a file from the server to the client drive. I have had no real problem using FTP_GET to transfer a file around the server where the PHP / FTP program is running. (Though, I did not think at first that I would need to enable Write privileges on the sub-directory where I had the PHP program, just assumed it was given.)I have searched with Google and read about 40 of the 900+ listings, all of which use the same two examples for FTP_GET, and I have checked a couple of forums, such as DevArticles (where the topic has been brought up with no answer). I am managing some files that cannot be displayed in a browser, such as TIFFs, where you would ordinarily right-click and select Save As...NOTE: I should also mention that a common example on the 'net shows that the destination file name includes C:\ as in "c:\testFile.txt". Do NOT include it. I included it in a test file name and ended up with a file named C: estFile.txt that I cannot delete from the directory. I am not a Linux/Unix head, just 20+ years in the DOS, Windows, Macintosh world (at MicroPro [yes, supporting WordStar 3.31], Broderbund, Borland, Novell, Tandem, etc.). So, I am not sure what the restriction is, probably should have used double-slash, but the PHP code did not burp.TIA,-Mac-

Link to comment
Share on other sites

I don't know much about this, but under quick functions in "PHP Your Visual Blueprint for Creating Open Source, Server-side Content" :Web sourceThis is what I find in the Quick Reference:

 ftp_get(ftp_stream, local_file, remote_file, mode)

downloads a file from an FTP server.

ftp_fput(ftp_stream,remote_file, fp, mode)

Uploads a file.

ftp_login(ftp_stream,username, password)

logs into an FTP connection.

(ftp_mkdir(ftp_stream, directory)

makes a directory on an FTP server.I don't know if any of this helps you as I have never tried this but here it is.Julia :)

Link to comment
Share on other sites

Hi Julia.Thanks for your input, but the information that you referenced is clear to me. The FTP_GET and all other FTP get functions only transfer to the 'server.' It is so weird that there is nothing that handles to the client (your personal computer). I expect that transferring to the client is going to require a custom library.-Mac-

Link to comment
Share on other sites

Hi Julia.Thanks for your input, but the information that you referenced is clear to me. The FTP_GET and all other FTP get functions only transfer to the 'server.' It is so weird that there is nothing that handles to the client (your personal computer). I expect that transferring to the client is going to require a custom library.-Mac-
I believe that this would be a breach of security. If this were possible, it would be far too easy to develop malicious code that could download a virus/trojan/worm to a user's hard drive. :thumbsdown: If you're looking to force the "Save As" box, this can be done with header()
Link to comment
Share on other sites

I thought the very first one would do that: ftp_getI don't find any other references and wonder if you have tested it to see if it works? Julia :thumbsdown:

Link to comment
Share on other sites

Next topic from me -- how do we use PHP or JavaScript to transfer a file from the server to the client drive. I have had no real problem using FTP_GET to transfer a file around the server where the PHP / FTP program is running. (Though, I did not think at first that I would need to enable Write privileges on the sub-directory where I had the PHP program, just assumed it was given.)I have searched with Google and read about 40 of the 900+ listings, all of which use the same two examples for FTP_GET, and I have checked a couple of forums, such as DevArticles (where the topic has been brought up with no answer). I am managing some files that cannot be displayed in a browser, such as TIFFs, where you would ordinarily right-click and select Save As...NOTE: I should also mention that a common example on the 'net shows that the destination file name includes C:\ as in "c:\testFile.txt". Do NOT include it. I included it in a test file name and ended up with a file named C: estFile.txt that I cannot delete from the directory. I am not a Linux/Unix head, just 20+ years in the DOS, Windows, Macintosh world (at MicroPro [yes, supporting WordStar 3.31], Broderbund, Borland, Novell, Tandem, etc.). So, I am not sure what the restriction is, probably should have used double-slash, but the PHP code did not burp.TIA,-Mac-
Just a quick note on the file you cannot delete:You are correct, the "C:\testfile.txt" should have been specified as "C:\\testfile.txt" in Javascript. You ended up with a tab character in the file name (C:{tab}estfile.txt). I guess the OS in it's infinite wisdom cannot deal with this internally.However, you should be able to delete the file from a shell (I am guessing you are in windows wherethat would be a command box, CMD.EXE). Just go to the root directory and type: DEL *estfile.txt.
Link to comment
Share on other sites

Hi Techie Wannabe,It is not a security issue. It is as if you are to use an FTP program, but do not want to give the visitor access to your FTP login info. The FTP commands allow the programmer to provide the visitor with the ability to upload without disclosing the login info. And FTP_GET allows a download to the server. Why not provide the programmer with the means to give the user a download to the client drive, controlled by the visitor, not pushed on to the visitor's hard by the program.Hi Julia, Obviously you have not tried to use the FTP_GET or FTP_FGET to 'download' files. Try to do it yourself. -Mac-

Link to comment
Share on other sites

Thanks,You are right that I am working from a Windows client system and connecting to a Linux server. I do not go to the root often and had forgotten. No problems when I was running Apache on my Windows box, but on the Linux, got this mistake. Ain't cross-platform fun!The problem came from the sample code from Mitchell Harper on DevArticles.com titled 'Building An FTP Client With PHP.' I have gotten the answers I have looked for for a long time about Blob fields and FTP from his articles there (as pointed out to me on the forum here), but in both cases, he has mistakes in his code, in this case leaving a dropping that has to be cleaned up (is it okay to say that?). His articles are worth learning from ... with caution.Thanks again to all for sharing, regardless of the results, and thanks to Scot!-Mac-

Link to comment
Share on other sites

If you're looking for a way to password-protect files, there's a better way to do that.If you're running Apache, you can create simple .htaccess and .htpasswd files that will do that.
Hi Techie Wannabe,Nope, as I keep saying, I want to write a PHP program that will let a visitor download files to their client machine. Just that, no protection, no sneakie downloads, all I want is to give them a list of files, they select and the program downloads TO the CLIENT, NOT to the SERVER.Thanks anyway,-Mac-
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...