mazazino Posted August 7, 2007 Share Posted August 7, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/63680-ftp_put-successfull-but-with-a-problem/ Share on other sites More sharing options...
Zane Posted August 7, 2007 Share Posted August 7, 2007 do you have your error_reporting set to E_ALL? if not just put this at the top of your script error_reporting(E_ALL); if you don't know that already. and tell us if that gives you anything new Quote Link to comment https://forums.phpfreaks.com/topic/63680-ftp_put-successfull-but-with-a-problem/#findComment-317367 Share on other sites More sharing options...
matto Posted August 7, 2007 Share Posted August 7, 2007 Just a thought - what's the site quota set to ? Also just looking at your code a bit closer - the following is opening you up for an attack //this will allow it be visible by the world, $ch=ftp_site($conn_id,"chmod 777 ".$destination_file); ....not only will the file be visible to the world, but it's also world writable..... Quote Link to comment https://forums.phpfreaks.com/topic/63680-ftp_put-successfull-but-with-a-problem/#findComment-317405 Share on other sites More sharing options...
mazazino Posted August 8, 2007 Author Share Posted August 8, 2007 Just a thought - what's the site quota set to ? Also just looking at your code a bit closer - the following is opening you up for an attack //this will allow it be visible by the world, $ch=ftp_site($conn_id,"chmod 777 ".$destination_file); ....not only will the file be visible to the world, but it's also world writable..... well i tried my entire code without the ftp_site() function but it didnt work for any file..when i added this function it worked..but i didnt know it would make users overwrite the file:S..but the only place anyone has access to file is through the administrator's page or by downloading it from the main page..could the user overwrite it through the main page?..if yes, how can i make it more secure? Quote Link to comment https://forums.phpfreaks.com/topic/63680-ftp_put-successfull-but-with-a-problem/#findComment-318229 Share on other sites More sharing options...
mazazino Posted August 8, 2007 Author Share Posted August 8, 2007 do you have your error_reporting set to E_ALL? if not just put this at the top of your script error_reporting(E_ALL); if you don't know that already. and tell us if that gives you anything new its not giving me an error..the problem is, i spoke to the web host and he said that the upload size limit is 2MB and i cant change it except by making a .htaccess file and setting some parameters in it straight..and when i asked him how to do that, he said that i cant do it if im on a windows machine...so any help? Quote Link to comment https://forums.phpfreaks.com/topic/63680-ftp_put-successfull-but-with-a-problem/#findComment-318231 Share on other sites More sharing options...
matto Posted August 8, 2007 Share Posted August 8, 2007 Could be worth considering using a *nix host. If there's no reason to write information to a file set the permissions accordingly (rw-r--r). Quote Link to comment https://forums.phpfreaks.com/topic/63680-ftp_put-successfull-but-with-a-problem/#findComment-318323 Share on other sites More sharing options...
mazazino Posted August 9, 2007 Author Share Posted August 9, 2007 can u tell me how to use and get in touch with a *nix host?..i might use another host if thats what it takes... Quote Link to comment https://forums.phpfreaks.com/topic/63680-ftp_put-successfull-but-with-a-problem/#findComment-319142 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.