Jump to content

PHP FTP vs. FTP Client


pets2soul

Recommended Posts

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);

}

?>

Link to comment
https://forums.phpfreaks.com/topic/255117-php-ftp-vs-ftp-client/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

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