[PHP] FTP functions
Hi I checked ou the ftp functions of PHP, what I wanted to ask was that if I connect to a remote server and issue and ftp_fget() command the file will be downloaded to the server running the PHP code and Apache webserver or the client machine from which we are calling it ? In the sense for example I have a client machine running on windows XP, I launch the mozilla firefox browser in that and call for the ftp_code.php on my server (http://server). The ftp_code.php contains a code which connects to a remote ftp server and then using the ftp_fget() function downloads a file from the remote server. Now where will this file be downloaded ? Though I have an inkling that since PHP is a server side scripting language, the file will be downloaded to the server only... But i still wanted to confirm Please confirm Thanks in advance Vaibhav Sibal -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] FTP functions
Hello! On Mon, 2005-03-07 at 18:20 +0530, Vaibhav Sibal wrote: Hi I checked ou the ftp functions of PHP, what I wanted to ask was that if I connect to a remote server and issue and ftp_fget() command the file will be downloaded to the server running the PHP code and Apache webserver or the client machine from which we are calling it ? In the sense for example I have a client machine running on windows XP, I launch the mozilla firefox browser in that and call for the ftp_code.php on my server (http://server). The ftp_code.php contains a code which connects to a remote ftp server and then using the ftp_fget() function downloads a file from the remote server. Now where will this file be downloaded ? The short answer is it would download it to the server, not the client on which Firefox is running. But if you were wanting to transfer the file to the client, I'd think you could do something creative like this: 1. Have your script download the file from the remote server. 2. Once the file has been downloaded, display a new page to the browser with a link to the file. 3. Then the user can click the link to retrieve/open the file. Now this may not be the best solution, it just happens to be what I could think of off the top of my head. There may be better ways to accomplish the same thing. Hope that helps! Tim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ftp functions not working
I am writing some backup scripts that will ftp my *.gz files to my ftp server. Unfortunately I didn't originally install php with ftp support (oversight on my part). I reconfigured/installed PHP with --enable-ftp and restarted everything, but the functions still don't work. #!/usr/local/bin/php ? if (function_exists('ftp_connect')): print cool\n; else: print damn\n; endif; ? output when ran: 'Damn' During the make I didn't see any errors. When I ran phpinfo() [http://www.randomthoughtprocess.com/info.php] it shows that I have FTP support. Is there something that I am missing? -- Cory Wiles Systems Engineer ePerformax - Memphis, TN 901.751.4902 http://www.eperformax.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ftp functions not working
Cory D. Wiles wrote: I am writing some backup scripts that will ftp my *.gz files to my ftp server. Unfortunately I didn't originally install php with ftp support (oversight on my part). I reconfigured/installed PHP with --enable-ftp and restarted everything, but the functions still don't work. #!/usr/local/bin/php ? if (function_exists('ftp_connect')): print cool\n; else: print damn\n; endif; ? output when ran: 'Damn' During the make I didn't see any errors. When I ran phpinfo() [http://www.randomthoughtprocess.com/info.php] it shows that I have FTP support. Is there something that I am missing? Did you install php cli binary? Is it installed in /usr/local/bin? Check the build date (/usr/local/bin/php -i | grep Build Date). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ftp functions not working
On Thursday 02 September 2004 22:43, Cory D. Wiles wrote: #!/usr/local/bin/php During the make I didn't see any errors. When I ran phpinfo() [http://www.randomthoughtprocess.com/info.php] it shows that I have FTP support. Is there something that I am missing? You're using php-cli. What does: /usr/local/bin/php -i | less show? -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Vulcans worship peace above all. -- McCoy, Return to Tomorrow, stardate 4768.3 */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ftp functions not working
#!/usr/local/bin/php ? if (function_exists('ftp_connect')): print cool\n; else: print damn\n; endif; ? output when ran: 'Damn' During the make I didn't see any errors. When I ran phpinfo() [http://www.randomthoughtprocess.com/info.php] it shows that I have FTP support. Is there something that I am missing? The version of PHP you're running on the command-line may or may not be the same installation as the one used by Apache. Use the following to see what your CLI installation does or does not have enabled: php -r phpinfo(); michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ftp functions not working
Marek Kilimajer wrote: Cory D. Wiles wrote: I am writing some backup scripts that will ftp my *.gz files to my ftp server. Unfortunately I didn't originally install php with ftp support (oversight on my part). I reconfigured/installed PHP with --enable-ftp and restarted everything, but the functions still don't work. #!/usr/local/bin/php ? if (function_exists('ftp_connect')): print cool\n; else: print damn\n; endif; ? output when ran: 'Damn' During the make I didn't see any errors. When I ran phpinfo() [http://www.randomthoughtprocess.com/info.php] it shows that I have FTP support. Is there something that I am missing? Did you install php cli binary? Is it installed in /usr/local/bin? Check the build date (/usr/local/bin/php -i | grep Build Date). I did install the php cli binary. It is in /usr/local/bin. Build Date = Jun 30 2004 22:27:26 -- Cory Wiles Systems Engineer ePerformax - Memphis, TN 901.751.4902 http://www.eperformax.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ftp functions not working
Michal Migurski wrote: #!/usr/local/bin/php ? if (function_exists('ftp_connect')): print cool\n; else: print damn\n; endif; ? output when ran: 'Damn' During the make I didn't see any errors. When I ran phpinfo() [http://www.randomthoughtprocess.com/info.php] it shows that I have FTP support. Is there something that I am missing? The version of PHP you're running on the command-line may or may not be the same installation as the one used by Apache. Use the following to see what your CLI installation does or does not have enabled: php -r phpinfo(); shell$php -r phpinfo(); | grep ftp Registered PHP Streams = php, http, ftp, compress.zlib shell$ I looked at the complete output and did not see that anything else for FTP. What do I need to do add FTP support for the CLI? michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- Cory Wiles Systems Engineer ePerformax - Memphis, TN 901.751.4902 http://www.eperformax.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ftp functions not working
mhhh.. try this: #!/usr/local/bin/php ? phpinfo(); ? and look on the console if you see ftp enabled... ¿do you have only ONE PHP INSTALL IN YOUR BOX?.. or two? On Thu, 02 Sep 2004 09:43:27 -0500, Cory D. Wiles [EMAIL PROTECTED] wrote: I am writing some backup scripts that will ftp my *.gz files to my ftp server. Unfortunately I didn't originally install php with ftp support (oversight on my part). I reconfigured/installed PHP with --enable-ftp and restarted everything, but the functions still don't work. #!/usr/local/bin/php ? if (function_exists('ftp_connect')): print cool\n; else: print damn\n; endif; ? output when ran: 'Damn' During the make I didn't see any errors. When I ran phpinfo() [http://www.randomthoughtprocess.com/info.php] it shows that I have FTP support. Is there something that I am missing? -- Cory Wiles Systems Engineer ePerformax - Memphis, TN 901.751.4902 http://www.eperformax.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Pablo M. Rivas. http://pmrivas.ipupdater.com --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ftp functions not working
I figured out why that it wasn't working. My prefix isn't the standard default prefix. I put php in /usr/local/apache/php. Though my script calls for /usr/local/bin/php...that php binary was copied there from the previous installation. Therefore, when I recompiled it was still using the 'old' binary. I should have created a symbolic link to the /usr/local/apache/php/bin/php file and this wouldn't have happened. Thanks for the quick repsonse. Marek Kilimajer wrote: Cory D. Wiles wrote: I am writing some backup scripts that will ftp my *.gz files to my ftp server. Unfortunately I didn't originally install php with ftp support (oversight on my part). I reconfigured/installed PHP with --enable-ftp and restarted everything, but the functions still don't work. #!/usr/local/bin/php ? if (function_exists('ftp_connect')): print cool\n; else: print damn\n; endif; ? output when ran: 'Damn' During the make I didn't see any errors. When I ran phpinfo() [http://www.randomthoughtprocess.com/info.php] it shows that I have FTP support. Is there something that I am missing? Did you install php cli binary? Is it installed in /usr/local/bin? Check the build date (/usr/local/bin/php -i | grep Build Date). -- Cory Wiles Systems Engineer ePerformax - Memphis, TN 901.751.4902 http://www.eperformax.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ftp functions not working
shell$php -r phpinfo(); | grep ftp Registered PHP Streams = php, http, ftp, compress.zlib shell$ I looked at the complete output and did not see that anything else for FTP. What do I need to do add FTP support for the CLI? Just to be absolutely sure, try to use `grep -i ftp` -- the FTP in FTP support = enabled is in all-caps. If it's still missing, you will need to recompile PHP. I'm not sure if you're on a shared host or not, but this actually does not demand root permissions - you can install a personal PHP binary in your home directory with all the required features, and use that. See the manual for relevant configuration details. michal migurski- contact info and pgp key: sf/cahttp://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ftp functions
Hi, I was just wondering given that only the standard FTP functions are supported by PHP, is there anyway to actually resume a download? The only thing that seems even capable of issuing any versatile commands is ftp_site, and that only issues site commands. I haven't had much luck with creating a socket connection to the server, and initiating the transfer that way. It has problems even logging in when I was testing it - not very promising. Any help/pointers would be appreciated, thanks Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ftp functions
disclamer Before I get flamed for not reading the manual or trying on my own, I would just like to say that I have been working on this for a few days and have read the manual and looked at quite a few examples, all of which seem to elude me. /disclamer I want to upload an image, and I want to use the ftp function to do so. I want to use the ftp functions for two reasons, (1) I have not used them yet, and (2) I will be loading an array with a list of files to be uploaded and I think the ftp functions are better suited for this (as opposed to the copy function). On to the trouble I can connect just fine. ? $ftp_server = xx.xx.xxx.xx; $ftp_user_name = username; $ftp_user_pass = password; // set up basic connection $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // check connection if ((!$conn_id) || (!$login_result)) { echo Ftp connection has failed!br; echo Attempted to connect to $ftp_server for user $ftp_user_namebr; die; } else { echo Connected to $ftp_server, for user $ftp_user_namebr; } //The file, even if I write the path out on my own, does not upload eventually I will have the path put in from a form. // upload the file $destination_file = /public_html/valeriemacwilliam/pics/$SID_.jpg; //(I have tried this without the beginning slash as well) $source_file = C:\\temp\\prestigecars\\bk_jag.jpg; $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY); // check upload status if (!$upload) { echo Ftp upload has failed!br; } else { echo Uploaded $source_file to $ftp_server as $destination_filebr; } //Even the ftp_close(function fails and causes an error); // close the FTP stream ftp_close($conn_id); ? Are the ftp functions depreciated? I have taken this example directly from the manual and editted the values to reflect my own situation but none of the function calls have been editted. Usually when this is the case I have just over looked something VERY simple and easy, please take a look and see what you can come up with. I would even be happy with an FAQ, I have been through the one on PHP.NET with no joy \C: PHP is the lastest release running on Mandrake 8.1 (w / plenty of horsepower) Thank you for your time. ~Curt~ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] ftp functions
one problem, the ftp functions that you are trying to use are on the server. therefor you are trying to connect one server to another server. you are not connecting from your workstation to the remote server. for what you are attempting to do, ftp will not work. Jim Lucas - Original Message - From: sundogcurt [EMAIL PROTECTED] To: GENERAL PHP LIST [EMAIL PROTECTED] Sent: Monday, January 21, 2002 10:47 AM Subject: [PHP] ftp functions disclamer Before I get flamed for not reading the manual or trying on my own, I would just like to say that I have been working on this for a few days and have read the manual and looked at quite a few examples, all of which seem to elude me. /disclamer I want to upload an image, and I want to use the ftp function to do so. I want to use the ftp functions for two reasons, (1) I have not used them yet, and (2) I will be loading an array with a list of files to be uploaded and I think the ftp functions are better suited for this (as opposed to the copy function). On to the trouble I can connect just fine. ? $ftp_server = xx.xx.xxx.xx; $ftp_user_name = username; $ftp_user_pass = password; // set up basic connection $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // check connection if ((!$conn_id) || (!$login_result)) { echo Ftp connection has failed!br; echo Attempted to connect to $ftp_server for user $ftp_user_namebr; die; } else { echo Connected to $ftp_server, for user $ftp_user_namebr; } //The file, even if I write the path out on my own, does not upload eventually I will have the path put in from a form. // upload the file $destination_file = /public_html/valeriemacwilliam/pics/$SID_.jpg; //(I have tried this without the beginning slash as well) $source_file = C:\\temp\\prestigecars\\bk_jag.jpg; $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY); // check upload status if (!$upload) { echo Ftp upload has failed!br; } else { echo Uploaded $source_file to $ftp_server as $destination_filebr; } //Even the ftp_close(function fails and causes an error); // close the FTP stream ftp_close($conn_id); ? Are the ftp functions depreciated? I have taken this example directly from the manual and editted the values to reflect my own situation but none of the function calls have been editted. Usually when this is the case I have just over looked something VERY simple and easy, please take a look and see what you can come up with. I would even be happy with an FAQ, I have been through the one on PHP.NET with no joy \C: PHP is the lastest release running on Mandrake 8.1 (w / plenty of horsepower) Thank you for your time. ~Curt~ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] ftp functions
Would you suggest that I use the copy function instead? I have tried the copy function in a prelim test and I had trouble with the function finding the file on the local machine. From what I have seen in the FAQs on PHPBUILDER and this is not an uncommon problem. One possible solution was that the path to the file to be uploaded must be relative to the location of the script. This doesn't make much sense to me though seeing as the file to be uploaded is on the local machine and the script on the remote machine. I'm drowning here, anybody have a rope? [EMAIL PROTECTED] wrote: one problem, the ftp functions that you are trying to use are on the server. therefor you are trying to connect one server to another server. you are not connecting from your workstation to the remote server. for what you are attempting to do, ftp will not work. Jim Lucas - Original Message - From: sundogcurt [EMAIL PROTECTED] To: GENERAL PHP LIST [EMAIL PROTECTED] Sent: Monday, January 21, 2002 10:47 AM Subject: [PHP] ftp functions disclamer Before I get flamed for not reading the manual or trying on my own, I would just like to say that I have been working on this for a few days and have read the manual and looked at quite a few examples, all of which seem to elude me. /disclamer I want to upload an image, and I want to use the ftp function to do so. I want to use the ftp functions for two reasons, (1) I have not used them yet, and (2) I will be loading an array with a list of files to be uploaded and I think the ftp functions are better suited for this (as opposed to the copy function). On to the trouble I can connect just fine. ? $ftp_server = xx.xx.xxx.xx; $ftp_user_name = username; $ftp_user_pass = password; // set up basic connection $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // check connection if ((!$conn_id) || (!$login_result)) { echo Ftp connection has failed!br; echo Attempted to connect to $ftp_server for user $ftp_user_namebr; die; } else { echo Connected to $ftp_server, for user $ftp_user_namebr; } //The file, even if I write the path out on my own, does not upload eventually I will have the path put in from a form. // upload the file $destination_file = /public_html/valeriemacwilliam/pics/$SID_.jpg; //(I have tried this without the beginning slash as well) $source_file = C:\\temp\\prestigecars\\bk_jag.jpg; $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY); // check upload status if (!$upload) { echo Ftp upload has failed!br; } else { echo Uploaded $source_file to $ftp_server as $destination_filebr; } //Even the ftp_close(function fails and causes an error); // close the FTP stream ftp_close($conn_id); ? Are the ftp functions depreciated? I have taken this example directly from the manual and editted the values to reflect my own situation but none of the function calls have been editted. Usually when this is the case I have just over looked something VERY simple and easy, please take a look and see what you can come up with. I would even be happy with an FAQ, I have been through the one on PHP.NET with no joy \C: PHP is the lastest release running on Mandrake 8.1 (w / plenty of horsepower) Thank you for your time. ~Curt~ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] ftp functions
the copy() function is subject to the same problem that the ftp functions are. you are trying to call a function that is on the remote server and you want it to do things to the local machine. unfortunatly you cannot do this. through a web browser you have no direct access to the local client machine. Jim - Original Message - From: sundogcurt [EMAIL PROTECTED] To: GENERAL PHP LIST [EMAIL PROTECTED] Sent: Monday, January 21, 2002 11:34 AM Subject: Re: [PHP] ftp functions Would you suggest that I use the copy function instead? I have tried the copy function in a prelim test and I had trouble with the function finding the file on the local machine. From what I have seen in the FAQs on PHPBUILDER and this is not an uncommon problem. One possible solution was that the path to the file to be uploaded must be relative to the location of the script. This doesn't make much sense to me though seeing as the file to be uploaded is on the local machine and the script on the remote machine. I'm drowning here, anybody have a rope? [EMAIL PROTECTED] wrote: one problem, the ftp functions that you are trying to use are on the server. therefor you are trying to connect one server to another server. you are not connecting from your workstation to the remote server. for what you are attempting to do, ftp will not work. Jim Lucas - Original Message - From: sundogcurt [EMAIL PROTECTED] To: GENERAL PHP LIST [EMAIL PROTECTED] Sent: Monday, January 21, 2002 10:47 AM Subject: [PHP] ftp functions disclamer Before I get flamed for not reading the manual or trying on my own, I would just like to say that I have been working on this for a few days and have read the manual and looked at quite a few examples, all of which seem to elude me. /disclamer I want to upload an image, and I want to use the ftp function to do so. I want to use the ftp functions for two reasons, (1) I have not used them yet, and (2) I will be loading an array with a list of files to be uploaded and I think the ftp functions are better suited for this (as opposed to the copy function). On to the trouble I can connect just fine. ? $ftp_server = xx.xx.xxx.xx; $ftp_user_name = username; $ftp_user_pass = password; // set up basic connection $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // check connection if ((!$conn_id) || (!$login_result)) { echo Ftp connection has failed!br; echo Attempted to connect to $ftp_server for user $ftp_user_namebr; die; } else { echo Connected to $ftp_server, for user $ftp_user_namebr; } //The file, even if I write the path out on my own, does not upload eventually I will have the path put in from a form. // upload the file $destination_file = /public_html/valeriemacwilliam/pics/$SID_.jpg; //(I have tried this without the beginning slash as well) $source_file = C:\\temp\\prestigecars\\bk_jag.jpg; $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY); // check upload status if (!$upload) { echo Ftp upload has failed!br; } else { echo Uploaded $source_file to $ftp_server as $destination_filebr; } //Even the ftp_close(function fails and causes an error); // close the FTP stream ftp_close($conn_id); ? Are the ftp functions depreciated? I have taken this example directly from the manual and editted the values to reflect my own situation but none of the function calls have been editted. Usually when this is the case I have just over looked something VERY simple and easy, please take a look and see what you can come up with. I would even be happy with an FAQ, I have been through the one on PHP.NET with no joy \C: PHP is the lastest release running on Mandrake 8.1 (w / plenty of horsepower) Thank you for your time. ~Curt~ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] FTP functions
I started to use FTP functions and I would greatly appreciate some confirmation : - It is not using FTP function than I can download file to a client's computer. (is there a way other than the A href=... ?) - I can not read the name of the files that are on a client's computer. (The client would select a folder on his local machine and would like to be able to get the list of files this folder contains) The idea of this is to be able to update semi-automatically a folder on a client's computer. There is a folder on the server containing files. The client points on his computer a folder to be compared to the one on the server. Comparison between the 2 folders is made and the files missing on the local machine are downloaded from the server. Am I completely dreaming or is there a way ? Thanks for your help. Pierre -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] FTP functions
I am trying to get a directory listing over ftp with the ftp_nlist() function. The problem is that the directory name has spaces in it and it looks like ftp_nlist() chops the string at each space and performs a separate listing for each word, which fails. I have tried quoting, urlencoding and rawurlencoding the string but nothing works. However, ftp_chdir() works when given the directory name with spaces. Is this a bug in ftp_nlist() or is it an undocumented feature? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]