PHP 8.5.0 Alpha 1 available for testing

Voting

: min(seven, six)?
(Example: nine)

The Note You're Voting On

Nate from ruggfamily.com
16 years ago
Here's a quick function that figures out the correct mode to use based on a file's extension.

<?php
function get_ftp_mode($file)
{
$path_parts = pathinfo($file);

if (!isset(
$path_parts['extension'])) return FTP_BINARY;
switch (
strtolower($path_parts['extension'])) {
case
'am':case 'asp':case 'bat':case 'c':case 'cfm':case 'cgi':case 'conf':
case
'cpp':case 'css':case 'dhtml':case 'diz':case 'h':case 'hpp':case 'htm':
case
'html':case 'in':case 'inc':case 'js':case 'm4':case 'mak':case 'nfs':
case
'nsi':case 'pas':case 'patch':case 'php':case 'php3':case 'php4':case 'php5':
case
'phtml':case 'pl':case 'po':case 'py':case 'qmail':case 'sh':case 'shtml':
case
'sql':case 'tcl':case 'tpl':case 'txt':case 'vbs':case 'xml':case 'xrc':
return
FTP_ASCII;
}
return
FTP_BINARY;
}

// sample usage
ftp_get($conn_id, $local_file, $server_file, get_ftp_mode($server_file));
?>

<< Back to user notes page

To Top