php写日志文件_PHP: file_put_contents - Manual

I made ​​a ftp_put_contents function.

hope you enjoy.

}

else {$fpc_file_name=$fpc_path_and_name;

}//Create local temp dirif (!file_exists($cfg_temp_folder)) {

if (!mkdir($cfg_temp_folder,0777)) {

echo"Unable to generate a temporary folder on the local server -$cfg_temp_folder.
";

die();

}

}//Create local file in temp dirif (!file_put_contents(str_replace("//","/",$cfg_temp_folder.$fpc_file_name),$fpc_content)) {

echo"Unable to generate the file in the temporary location - ".str_replace("//","/",$cfg_temp_folder.$fpc_file_name).".
";

die();

}//Connection to the FTP Server$fpc_ftp_conn=ftp_connect("$cfg_ftp_server");//Check connectionif (!$fpc_ftp_conn) {

echo"Could not connect to server $cfg_ftp_server.
";

die();

}

else {// login

// check username and passwordif (!ftp_login($fpc_ftp_conn,"$cfg_user","$cfg_pass")) {

echo"User or password.
";

die();

}

else {//Document Rootif (!ftp_chdir($fpc_ftp_conn,$cfg_document_root)) {

echo"Error to set Document Root.
";

die();

}//Check if there are folders to createif ($cotains_slash) {//Check if have folders and is not just the file nameif (count($fpc_path_and_name_array) >1) {//Remove last array$fpc_remove_last_array=array_pop($fpc_path_and_name_array);//Checks if there slashs on the pathif (substr($fpc_path_and_name,0,1) =="/") {$fpc_remove_first_array=array_shift($fpc_path_and_name_array);

}//Create each folder on ftpforeach ($fpc_path_and_name_arrayas$fpc_ftp_path) {

if (!@ftp_chdir($fpc_ftp_conn,$fpc_ftp_path)) {

if (!ftp_mkdir($fpc_ftp_conn,$fpc_ftp_path)) {

echo"Error creating directory$fpc_ftp_path.
";

}

else {

if (!ftp_chdir($fpc_ftp_conn,$fpc_ftp_path)) {

echo"Error go to the directory$fpc_ftp_path.
";

}

}

}

}

}

else {

}

}//Check upload fileif (!ftp_put($fpc_ftp_conn,$fpc_file_name,str_replace("//","/",$cfg_temp_folder.$fpc_file_name),FTP_ASCII)) {

echo"File upload $fpc_path_and_name failed!
";

die();

}

else {

if (!unlink(str_replace("//","/",$cfg_temp_folder.$fpc_file_name))) {

echo"Error deleting temporary file.
";

die();

}

else {

echo"File upload $cfg_site_link".str_replace("//","/","/$fpc_path_and_name")." successfully performed.
";

}

}//Close connection to FTP serverftp_close($fpc_ftp_conn);

}

}

}#Sample$content_file=""-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">

Title

Test

";ftp_put_contents("test.php",$content_file);?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值