Jump to content

Recommended Posts

Hi

 

I have a form which is used to upload files to my server, now i need to move files to another server as soon they are uploaded, but move_uploaded_file will work with local server where form has been submitted.

 

i was thinking to add some ftp functions to upload that file to remote server but is there any better way?  that user dont notice ftp connection timing. i wants to use less ftp connections and user should not notice delay timing for image upload.

 

Thanks  for any suggestion.

Link to comment
https://forums.phpfreaks.com/topic/246090-file-upload-to-another-server/
Share on other sites

If you're going to be transferring a file from server to server then there is always going to be a delay, the length of which depends on the filesize and both servers internet connection speeds. There is no avoiding that unfortunately.

 

FTP is a good way of doing it, I would do it that way. Another option is to expose the file to the public folder where the other server can download it via HTTP. Using that method though you would have to lock down the folder so that only the other server can access it, using a htaccess IP check for example. You would have to call a script on the other server to invoke the download.

 

Another option is to do nothing when the file is uploaded, and have a cron job that runs each day or every few hours, which will send any uploaded files to other server. The benefit here is the user won't experience any delay after the upload, but obviously the downside is the file won't appear on the other server until the cron runs - this may or may not be convenient for you.

there's yet another option, which is a variation of one of the previous. As the182guy said:

Another option is to do nothing when the file is uploaded, and have a cron job that runs each day or every few hours, which will send any uploaded files to other server. The benefit here is the user won't experience any delay after the upload, but obviously the downside is the file won't appear on the other server until the cron runs - this may or may not be convenient for you.

 

you could do this, but call a script on the server and send it the url of where the file resides at the moment. This way, when users visit you site, they will see ALL uploads available, even though some of them have not yet been moved to the server, they can still be downloaded. then when the cron job finally executes, you also change the url to the appropriate path.

First of all thanks the182guy for suggestion, and thank you WebStyles too for contributing.

 

Actually i forget to mention sir, its an image hosting type script, and i wants to host images on sub-dmains so i can split server load to various sub-domains on other servers. so now i am generating a link like this

 

http://mysite.com/SomeRandmID/filename.image

 

so user can use above link to share there images. Now if i use that method which you are both suggesting, how can i manage that. so actual image link user will get as below.

 

http://sub-domain.mysite.com/SomeRandmID/filename.image

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.