AbydosGater Posted May 12, 2007 Share Posted May 12, 2007 Hey guys, Im writing a script that connects to one ftp server downloads files to my computer, uploads them to a second and then deletes them from my comp. I tried running it last night and all went bad. From what i can tell most errors have been fixed except one. My php error log is showing hundreds and hundreds of the following: [12-May-2007 02:28:47] PHP Warning: ftp_get(): 7858.4 kbytes to download in C:\apache2triad\htdocs\ftp\swf\main.php on line 38 Is that a limit thats set somewhere that it cant download a file that size? There are LOADS of that error. The script downloaded about 100 of the files but there are over 1000, and the rest didnt get downloaded cause of this error. Anyone know whats causing it? Thank you so much, Andy Quote Link to comment https://forums.phpfreaks.com/topic/51060-ftp-script-limits/ Share on other sites More sharing options...
chigley Posted May 12, 2007 Share Posted May 12, 2007 No guarantee this will work but after trawling through php.ini it looks like these four options may allow you to tweak them to allow your script to deal with larger files! <?php ini_set("post_max_size", "value"); // Default 8M ini_set("max_execution_time", "value"); // Default 30 (seconds) ini_set("memory_limit", "value"); // Default 8M ini_set("upload_max_filesize", "value"); // Default 2M /* Your code here */ ?> Not 100% sure if that will work, but it's worth a go Quote Link to comment https://forums.phpfreaks.com/topic/51060-ftp-script-limits/#findComment-251278 Share on other sites More sharing options...
MadTechie Posted May 12, 2007 Share Posted May 12, 2007 can you post the main.php script (IN code tags), Quote Link to comment https://forums.phpfreaks.com/topic/51060-ftp-script-limits/#findComment-251280 Share on other sites More sharing options...
AbydosGater Posted May 12, 2007 Author Share Posted May 12, 2007 Yeah thats chigley, the problem in php.ini the resource limits.. max_execution_time = 30 ; Maximum execution time of each script, in seconds max_input_time = 300 ; Maximum amount of time each script may spend parsing request data memory_limit = 80000M ; Maximum amount of memory a script may consume (8MB) It was set to only 8M so i put a few 0's after it only for the moment Here is the script.. It gave me a bit of a scare there, with the new ini settings the script ran, but it ran twice, downloading the files to 2 different folders. and when i killed the script, it didnt stop downloading to one of the folders, so i killed apache.. and that didnt even stop it. But lucky enough apache crashed and it stopped Here is the code. <?php function slog($string){ $fp = fopen('log.txt', 'a'); fputs($fp, $string . ' '); fclose($fp); } slog('STARTING PROCESS AT: ' . gmdate("l dS \of F Y h:i:s A")); set_time_limit(300000); $game_host = ''; $game_user = ''; $game_pass = ''; $game_dir = '/public_html/old/swf/'; $game_conn = ftp_connect($game_host); $flash_host = ''; $flash_user = ''; $flash_pass = ''; $flash_dir = '/public_html/swf/'; $flash_conn = ftp_connect($flash_host); $my_dir = '/apache2triad/htdocs/ftp/swf'; if (!$game_conn){ die('Could not connect to server: ' . $game_host); } if (!ftp_login($game_conn, $game_user, $game_pass)){ ftp_quit($conn); exit('Failed to login to GAME with supplied details.'); } ftp_chdir($game_conn, $game_dir); $swf_files = ftp_nlist($game_conn, $game_dir); opendir($my_dir); for($i=0;$i<count($swf_files);$i++) { if(!ftp_get($game_conn,$swf_files[$i],$swf_files[$i],FTP_BINARY)) { echo 'Could not download ' . $files[$i]; } else { echo 'Got a file! '; } } echo 'All Files Downloaded '; slog('All Files Downloaded: ' . gmdate("l dS \of F Y h:i:s A")); ftp_quit($game_conn); $dp = opendir($my_dir); while ($currentFile !== false){ $currentFile = readdir(); $theFiles[] = $currentFile; } $swfFiles = preg_grep("/swf$", $theFiles); foreach ($swfFiles as $currentFile){ ftp_put($flash_conn, $currentFile, $currentFile, FTP_BINARY); echo 'Uploaded ' . $currentFile . ' '; } echo 'All Files Uploaded '; slog("All Files Uploaded: " . gmdate("l dS \of F Y h:i:s A")); ftp_quit($flash_conn); echo 'Deleting Files Now'; foreach ($swfFiles as $currentFile){ unlink($currentFile); echo 'Deleted: ' . $currentFiles; } slog('Ending process at: ' . gmdate("l dS \of F Y h:i:s A")); ?> I think that would have fixed it, anything else wrong? Quote Link to comment https://forums.phpfreaks.com/topic/51060-ftp-script-limits/#findComment-251284 Share on other sites More sharing options...
chigley Posted May 12, 2007 Share Posted May 12, 2007 So does it work now with the ini_set()s or by changing your PHP.ini? Quote Link to comment https://forums.phpfreaks.com/topic/51060-ftp-script-limits/#findComment-251288 Share on other sites More sharing options...
AbydosGater Posted May 12, 2007 Author Share Posted May 12, 2007 I changed the php.ini but im using ini_set for the max time limit. Quote Link to comment https://forums.phpfreaks.com/topic/51060-ftp-script-limits/#findComment-251290 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.