pets2soul Posted January 16, 2012 Share Posted January 16, 2012 Dear all, I'm working on a website that is hosted on a server with 10Mb of file size limit via HTTP file uploading approach (eg. PHP file uploading form using move_uploaded_file()), although there's no file size limit via FTP file uploading approach (eg. Using FTP client). Therefore, I was thinking about using PHP FTP functions to bypass the file size limit. However, when I upload file bigger than 10Mb, I still got this error message telling me that my file can't be over 10Mb... So my question is...what exactly are the differences between PHP FTP and FTP Client, that the web server used to determine whether to block the file bigger than 10Mb or not? Thank you very much! Below is my code: <?php echo '<form action="" method="post" enctype="multipart/form-data">'; echo 'Click the Browse button to find the file you wish to upload'; echo '<input type="file" name="add_file">'; echo '<INPUT TYPE="submit" name="upload" value="upload">'; echo '</form>'; if($_POST['upload']) { $add_file = $_FILES['add_file']; //change these values to suit your site $ftp_user_name = 'username'; $ftp_user_pass = 'password'; $ftp_server = 'ftp.domainname.com'; $ftp_root = '/'; //File upload $temp_path = $ftp_root . $add_file['tmp_name']; $target_path = basename($add_file['name']); $max_size = 26214400; if($add_file['error'] == 0 && $add_file['size'] < $max_size) { // set up basic connection $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // upload a file ftp_chdir($conn_id, '/root/second/'); if (ftp_put($conn_id, $target_path, $temp_path, FTP_ASCII)) { echo "successfully uploaded " . $target_path; } else { echo "There was a problem while uploading " . $target_path; } } else { echo "There's been an error, please try again later."; } // close the connection ftp_close($conn_id); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/255117-php-ftp-vs-ftp-client/ Share on other sites More sharing options...
scootstah Posted January 16, 2012 Share Posted January 16, 2012 Why did you think the upload limit would magically be gone by using FTP instead? You are still uploading a file through a form, and the limit still exists. Quote Link to comment https://forums.phpfreaks.com/topic/255117-php-ftp-vs-ftp-client/#findComment-1308067 Share on other sites More sharing options...
pets2soul Posted January 16, 2012 Author Share Posted January 16, 2012 Hi scootstah, thanks for your reply. So you are saying what the server determines the file size limit is by the front-end, not the approach where the file is going into? Let me put this also into circumstance: The form itself is not on the same server, the form itself is on another server with another web hosting company. Quote Link to comment https://forums.phpfreaks.com/topic/255117-php-ftp-vs-ftp-client/#findComment-1308070 Share on other sites More sharing options...
scootstah Posted January 16, 2012 Share Posted January 16, 2012 If there is a limit on the upload size then it doesn't matter what you do after you upload it. It will fail before it even gets to that point. If you have access to the php.ini file you may be able to increase the limits. Quote Link to comment https://forums.phpfreaks.com/topic/255117-php-ftp-vs-ftp-client/#findComment-1308071 Share on other sites More sharing options...
pets2soul Posted January 16, 2012 Author Share Posted January 16, 2012 Umm...maybe I didn't explain it clearly...but 10Mb is the size per file uploaded through HTTP; however, there is no file size limit at all for files uploaded through FTP. Quote Link to comment https://forums.phpfreaks.com/topic/255117-php-ftp-vs-ftp-client/#findComment-1308089 Share on other sites More sharing options...
scootstah Posted January 16, 2012 Share Posted January 16, 2012 You are uploading it through HTTP either way. Quote Link to comment https://forums.phpfreaks.com/topic/255117-php-ftp-vs-ftp-client/#findComment-1308188 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.