rajeshkr Posted April 28, 2014 Share Posted April 28, 2014 Hi, I am using a unlimited server for uploading some files but after using so many code , i am not able to achieve my goal. So now i want i use my current server to php code and upload my files into another server, where limit will not be any issue. Example. Let's say i have two server ( www.rajesh.com and www.rathor.com), now i am using below code into www.rajesh.com if (file_exists("http://www.rathor.com/demo/rajesh/" . $_FILES["uploadedfile"]["name"])) { echo $_FILES["uploadedfile"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["uploadedfile"]["tmp_name"], "http://www.rathor.com/demo/rajesh/" . $_FILES["uploadedfile"]["name"]); echo "Stored in: " . "http://www.rathor.com/demo/rajesh/" . $_FILES["uploadedfile"]["name"]; } So i just want to know, is it possible to do?if yes then how i can achieve this?Thanks Quote Link to comment https://forums.phpfreaks.com/topic/288079-how-to-upload-a-file-into-a-server-using-code-in-another-server-using-php/ Share on other sites More sharing options...
mac_gyver Posted April 28, 2014 Share Posted April 28, 2014 most of the functions you have in your code won't work using the http:// protocol, and even if they did, what you are doing would be uploading the file to the first server, then moving it to the second server. this would use double your file transfer bandwidth on the first server. so, what exact problem are you trying to solve. Quote Link to comment https://forums.phpfreaks.com/topic/288079-how-to-upload-a-file-into-a-server-using-code-in-another-server-using-php/#findComment-1477511 Share on other sites More sharing options...
Cornelius Posted April 28, 2014 Share Posted April 28, 2014 (edited) Doing it your way, anyone could make a script that would transfer his files into your folder on your server. That's why it shouldn't work. You should probably look into FTP section. As an example: $ftp_server=""; $ftp_user_name=""; $ftp_user_pass=""; $file = "";//tobe uploaded $remote_file = ""; // set up basic connection $conn_id = ftp_connect($ftp_server)or die("Unable to connect to server."); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // upload a file if (ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) { echo "successfully uploaded $file\n"; exit; } else { echo "There was a problem while uploading $file\n"; exit; } // close the connection ftp_close($conn_id); Edited April 28, 2014 by Cornelius Quote Link to comment https://forums.phpfreaks.com/topic/288079-how-to-upload-a-file-into-a-server-using-code-in-another-server-using-php/#findComment-1477522 Share on other sites More sharing options...
rajeshkr Posted April 29, 2014 Author Share Posted April 29, 2014 most of the functions you have in your code won't work using the http:// protocol, and even if they did, what you are doing would be uploading the file to the first server, then moving it to the second server. this would use double your file transfer bandwidth on the first server. so, what exact problem are you trying to solve. Hi mac_gyver, as i mention , i am trying to give user permission to upload files that may be more than 300Mb size but as i increase sizes in php.in, in my php file and in .htaccess file also but it only able to take 20Mb not more than that, so i was thinking if i could transfer to any other server using any mode like you said ftp, thank i could able to achieve my goal. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/288079-how-to-upload-a-file-into-a-server-using-code-in-another-server-using-php/#findComment-1477590 Share on other sites More sharing options...
mac_gyver Posted April 29, 2014 Share Posted April 29, 2014 as i mention , i am trying to give user permission to upload files that may be more than 300Mb size no, you didn't mention that in this thread. you cannot assume anyone reading your thread knows anything about your previous threads or problems or how this tread relates to any previous thread or problem. have you checked with your web host to find the proper method of changing the upload file size limits on their server? you cannot set them in your .php file because php uses the settings before your php script is even executed. you can only set them in a .htaccess file when php is running as an Apache Server Module (you get a server if you try.) you can set them in a local php.ini when php is running as a cgi/fastcgi application. if your upload script is in a folder, you will likely need to have a php,ini file in the same folder where the script is at. some web hosts use a different name for the php.ini file, such as php5.ini. you must find out if your web host allows you to change the two settings at all (both post_max_size and upload_max_filesize must be change and they must be set to realistic and valid values) and where and how to change them. Quote Link to comment https://forums.phpfreaks.com/topic/288079-how-to-upload-a-file-into-a-server-using-code-in-another-server-using-php/#findComment-1477603 Share on other sites More sharing options...
rajeshkr Posted April 30, 2014 Author Share Posted April 30, 2014 no, you didn't mention that in this thread. you cannot assume anyone reading your thread knows anything about your previous threads or problems or how this tread relates to any previous thread or problem. have you checked with your web host to find the proper method of changing the upload file size limits on their server? you cannot set them in your .php file because php uses the settings before your php script is even executed. you can only set them in a .htaccess file when php is running as an Apache Server Module (you get a server if you try.) you can set them in a local php.ini when php is running as a cgi/fastcgi application. if your upload script is in a folder, you will likely need to have a php,ini file in the same folder where the script is at. some web hosts use a different name for the php.ini file, such as php5.ini. you must find out if your web host allows you to change the two settings at all (both post_max_size and upload_max_filesize must be change and they must be set to realistic and valid values) and where and how to change them. Hi mac_gyver, First of all sorry for inconvenience, My host server is bluehost. i am using php.ini file (5.4 as per control panel of bluehost). Earlier i was getting error because there was mas 10 MB set for upload limit, then i change into php.ini file to 512 MB for both post_max_size and upload_max_filesize and change the max_execution time limit too. but now after changing it too, i only able to upload 20 MB not more than that. I have try everything but it dosen't seem to help me. i will only left with what you said use php.ini file in same folder. Let me check with this also and will reply if it worked Thanks Quote Link to comment https://forums.phpfreaks.com/topic/288079-how-to-upload-a-file-into-a-server-using-code-in-another-server-using-php/#findComment-1477677 Share on other sites More sharing options...
bsmither Posted April 30, 2014 Share Posted April 30, 2014 Apache has a limit: check with your host. Quote Link to comment https://forums.phpfreaks.com/topic/288079-how-to-upload-a-file-into-a-server-using-code-in-another-server-using-php/#findComment-1477678 Share on other sites More sharing options...
rajeshkr Posted April 30, 2014 Author Share Posted April 30, 2014 hi mac_gyver,, Still no luck same error. 500 Server ErrorA misconfiguration on the server caused a hiccup. Check the server logs, fix the problem, then try again. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/288079-how-to-upload-a-file-into-a-server-using-code-in-another-server-using-php/#findComment-1477681 Share on other sites More sharing options...
rajeshkr Posted April 30, 2014 Author Share Posted April 30, 2014 Apache has a limit: check with your host. Hi bsmithe, The limit shown is upto 2 GB but i am not able to upload more than 20 MB. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/288079-how-to-upload-a-file-into-a-server-using-code-in-another-server-using-php/#findComment-1477682 Share on other sites More sharing options...
bsmither Posted April 30, 2014 Share Posted April 30, 2014 Between one byte and 2GB is the range of this setting that Apache can work with. The server administrator may set this limit in the web server's configuration file to a value that the web server administrator has chosen to be appropriate - perhaps 20MB. Please consult your hosting provider. Quote Link to comment https://forums.phpfreaks.com/topic/288079-how-to-upload-a-file-into-a-server-using-code-in-another-server-using-php/#findComment-1477684 Share on other sites More sharing options...
Cornelius Posted May 2, 2014 Share Posted May 2, 2014 I'm still not sure what are you trying to do? Do you want users to transfer files from one server to another or what? If not, why are you doing it in PHP? You can do it in CPanel, just make sure (as they said above) with server admins what's the limit. Quote Link to comment https://forums.phpfreaks.com/topic/288079-how-to-upload-a-file-into-a-server-using-code-in-another-server-using-php/#findComment-1477888 Share on other sites More sharing options...
rajeshkr Posted May 3, 2014 Author Share Posted May 3, 2014 I'm still not sure what are you trying to do? Do you want users to transfer files from one server to another or what? If not, why are you doing it in PHP? You can do it in CPanel, just make sure (as they said above) with server admins what's the limit. Hi, 1- I have a registration page for user. 2- After registration in page , they will login into page. 3- There will be a simple browse (upload button) and php code into server 1 suppose, mysite.com. but this is a shared server so i am not able to upload a file more then 20MB of size and after lot of code changes , i couldn't able to do into this server. 4- So i have an other server 2 myserver.com as dedicated server, where there is no limit to upload. 5- Now i want could i user server 1 to upload into server 2. Hope you understand what i want. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/288079-how-to-upload-a-file-into-a-server-using-code-in-another-server-using-php/#findComment-1478010 Share on other sites More sharing options...
Cornelius Posted May 11, 2014 Share Posted May 11, 2014 Yes I understand now. You should try file upload to get document on server1, and then FTP to get them from on server1 to server2. Quote Link to comment https://forums.phpfreaks.com/topic/288079-how-to-upload-a-file-into-a-server-using-code-in-another-server-using-php/#findComment-1479034 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.