mraza Posted August 31, 2011 Share Posted August 31, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/246090-file-upload-to-another-server/ Share on other sites More sharing options...
the182guy Posted August 31, 2011 Share Posted August 31, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/246090-file-upload-to-another-server/#findComment-1263848 Share on other sites More sharing options...
WebStyles Posted August 31, 2011 Share Posted August 31, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/246090-file-upload-to-another-server/#findComment-1263883 Share on other sites More sharing options...
mraza Posted August 31, 2011 Author Share Posted August 31, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/246090-file-upload-to-another-server/#findComment-1263894 Share on other sites More sharing options...
mraza Posted September 1, 2011 Author Share Posted September 1, 2011 any idea please anyone? Quote Link to comment https://forums.phpfreaks.com/topic/246090-file-upload-to-another-server/#findComment-1264541 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.