/    Sign up×
Community /Pin to ProfileBookmark

ftp_put() successfull but with a problem

Hi, i used the following code to upload large files ranging 1-50 MB..the problem is i tried uploading a file of size 1.78 MB and it worked..then i tried uploading a file 2.9 MB and it didn’t work..then i tried a uploading a file of size 2.18 MB and it also didnt work..by didnt work i mean that when checking the directory online, there is a file with the name of the uploaded file but its size is 0 bytes!!…i mean the uploading is fine, but the size is the problem..
the upload_max_filesize is set to 60MB just to make sure in wont cause a problem so im pretty sure that’s not my problem..can anyone help?…

$ftp_server = “//ftp server”;
$conn_id = ftp_connect($ftp_server);

// login with username and password
$ftp_user_name = “//username”;
$ftp_user_pass = “//password”;
$ftp_dir=’/HOSTNAME.com/extras/softwares/’.$cat;

//$web_location is needed for the file_exists function, the directories used by FTP
//are not visible to it will will always return not found.
$web_dir=’../../extras/softwares/’.$cat;
$local_file_name = $_FILES[‘directory’][‘name’];//”file.txt”;
$source_file = $_
FILES[‘directory’][‘tmp_name’];
$web_location=$web_dir.$local_file_name;

//build a fully qualified (FTP) path name where the file will reside
$destination_file=$ftp_dir.$local_file_name;

$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// check connection
if ((!$conn_id) || (!$login_result)) {
echo “FTP connection has failed!”;
echo “Attempted to connect to $ftp_server for user $ftp_user_name”;
exit;
} else {
echo “Connected to $ftp_server, for user $ftp_user_name”;
}
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);

// check upload status
if (!$upload) {
echo “FTP upload has failed!”;
} else {
echo “Uploaded $source_file to $ftp_server as $destination_file”;
}

//use ftp_site to change mode of the file
//this will allow it be visible by the world,
$ch=ftp_site($conn_id,”chmod 777 “.$destination_file);
// close the FTP stream
ftp_close($conn_id);
//verify file was written
if (file_exists($web_location))
{
echo “file was uploaded as $web_location”;
}
else
{
echo “Could not create $web_location”;
}
//end if

to post a comment
PHP

8 Comments(s)

Copy linkTweet thisAlerts:
@MrCoderAug 07.2007 — Could it be that set_time_limit(0) is required?
Copy linkTweet thisAlerts:
@mazazinoauthorAug 07.2007 — no i talked to my webhosting service and they said that theres something called WebShell3 that limits the upload size to 2 mb..and they saaid i cant change it unless i make a .htaccess file and set some parameters in it, but they said i cant make an .htaccess file except if im on linux, which im not, so theres my problem once again..if anyone cud help;;
Copy linkTweet thisAlerts:
@MrCoderAug 07.2007 — I think only your web host can help you since there set-up is flawed.

If your having problems creating a .htaccess file in windows I believe *most* ftp software will let you create the file on your server. (DreamWeaver does allow this)
Copy linkTweet thisAlerts:
@mazazinoauthorAug 07.2007 — can u guide me through creating a .htaccess file?..i mean im in desperate need of figuring this out soon..
Copy linkTweet thisAlerts:
@MrCoderAug 07.2007 — Only if you use the same FTP software as me.

There are plenty of guides / tutorials on the net, why not just google ".htaccess"
Copy linkTweet thisAlerts:
@mazazinoauthorAug 07.2007 — im using cute FTP..is that the same one ur using?
Copy linkTweet thisAlerts:
@MrCoderAug 07.2007 — No, I use DreamWeaver and WinSCP3
Copy linkTweet thisAlerts:
@knowjAug 07.2007 — to make a .htaccess file open up notepad

save as > change file type to all files > name the file .htaccess

then just copy/paste/type in the information you need to go into the htaccess file.

your web host sounds like they don't know what there on about
×

Success!

Help @mazazino spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.22,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...