Page 1 of 1
PHP File Upload to remote server
Posted: Thu Jul 09, 2009 6:16 am
by kishore_marti
Hi Friends,
This is my first post in the forum.
I am working on a healthcare web application being developed in PHP. We have a functionality where the user would upload the files and they should be stored on a remote server. In short the uploaded files should be stored on a remote server and should be retrieved from there.
Can you please let me know how to achieve this in PHP.
Your help is greatly appreciated.
Thank You
Kishore
Re: PHP File Upload to remote server
Posted: Thu Jul 09, 2009 6:18 am
by SvanteH
I'm actually looking for a similar solution. One would be using the PUT-request to transfer the file (upload it to the server) then using GET-request to start the file download. I'm guessing you do not want the user to handle directly to the file server thus the script would work as a proxy.
Re: PHP File Upload to remote server
Posted: Thu Jul 09, 2009 8:48 am
by jackpf
I made one of these a while ago using curl. It's pretty easy...just read up on curl.
You can check mine out on my site...it's in the options for posting/sending messages. I don't like to host uploaded files on my own server (for bandwidth and security reasons) so I upload uploaded files to a file host server.
If you have any specific problems I'd be happy to help.
Re: PHP File Upload to remote server
Posted: Fri Jul 10, 2009 4:32 am
by kishore_marti
Thank you guys for taking your time off and posting the replies
Can you please let me know the curl code to upload file to server. Does this require any install of the software (any library files).
I have reviewed the PHP documentation but could not get much out of it..
Thanks for all your help
Kishore
Re: PHP File Upload to remote server
Posted: Fri Jul 10, 2009 4:35 am
by VladSun
kishore_marti wrote:Can you please let me know how to achieve this in PHP.
Is it necessary to use PHP?
A simple call to "scp" or whatever remote copy command (these are for Linux) is simple enough.
Re: PHP File Upload to remote server
Posted: Fri Jul 10, 2009 6:35 am
by kishore_marti
Hi Friend,
Thanks for your suggestion.. We are working on a project being developed in PHP where uploading files is one of the functionality.. So this has to be done in PHP.
Please let me know if the scp command that you mentioned can somehow be executed through PHP..
Thanks
Kishore
Re: PHP File Upload to remote server
Posted: Fri Jul 10, 2009 6:38 am
by VladSun
http://us3.php.net/manual/en/function.ssh2-scp-send.php
Code: Select all
$conn = ssh2_connect('ssh.server.com', 22);
ssh2_auth_password($conn 'user', 'pass');
ssh2_scp_send($conn, '/local/filename', '/remote/filename', 0644);
Re: PHP File Upload to remote server
Posted: Sat Jul 11, 2009 12:00 am
by kishore_marti
Thanks for your reply
Can you please let me know where can i download php_ssh2.dll. I couldn't find one in PHP site
Thanks
Kishore
Re: PHP File Upload to remote server
Posted: Sat Jul 11, 2009 2:20 am
by kishore_marti
Thanks for the reply.
I really like the prompt response that I am getting here..
I will try the options mentioned above and let you know..
I thank all of you guys..
Re: PHP File Upload to remote server
Posted: Tue Jul 14, 2009 11:35 pm
by kishore_marti
Friends,
I tried connecting to FTP server through PHP ftp_connect and transfer files there using ftp_put.. but i am receiving the "Could not create file" exception when the command ftp_put is executed.. I have verified the status of the connection and it is able to connect to ftp server.. but not able to transfer files to server..
Can you please help me out in this issue..
Thanks
Kishore