PHP File Upload to remote server

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kishore_marti
Forum Newbie
Posts: 8
Joined: Thu Jul 09, 2009 6:10 am

PHP File Upload to remote server

Post 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
SvanteH
Forum Commoner
Posts: 50
Joined: Wed Jul 08, 2009 12:25 am

Re: PHP File Upload to remote server

Post 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.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: PHP File Upload to remote server

Post 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.
kishore_marti
Forum Newbie
Posts: 8
Joined: Thu Jul 09, 2009 6:10 am

Re: PHP File Upload to remote server

Post 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
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: PHP File Upload to remote server

Post 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.
There are 10 types of people in this world, those who understand binary and those who don't
kishore_marti
Forum Newbie
Posts: 8
Joined: Thu Jul 09, 2009 6:10 am

Re: PHP File Upload to remote server

Post 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
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: PHP File Upload to remote server

Post 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);
There are 10 types of people in this world, those who understand binary and those who don't
kishore_marti
Forum Newbie
Posts: 8
Joined: Thu Jul 09, 2009 6:10 am

Re: PHP File Upload to remote server

Post 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
kishore_marti
Forum Newbie
Posts: 8
Joined: Thu Jul 09, 2009 6:10 am

Re: PHP File Upload to remote server

Post 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..
kishore_marti
Forum Newbie
Posts: 8
Joined: Thu Jul 09, 2009 6:10 am

Re: PHP File Upload to remote server

Post 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
Post Reply