function saveFileFromWeb($http_url , $save_file_path, $MediaType)
{
$download_info = load_remote_file($http_url, $save_file_path);
if($download_info)
{
$info = stat($save_file_path);
$size = $info[7];
//TODO: add more $MediaType
$MediaType = strtoupper($MediaType);
if( !in_array( $MediaType , array( "IMAGE" ) ) )
{
return array(false , "This Media type ($MediaType) is not allowed");
}
$file_info = getimagesize($save_file_path);
$w = $file_info[0];
$h = $file_info[1];
// save file info to db
$file_item = array(
"Name" => basename($save_file_path),
"Size" => $size,
"Width" => $w,
"Height" => $h,
"MediaType" => $MediaType,
"PathType" => "LOCALFILE",
"FilePath" => $save_file_path,
"Status" => 1,
"ActiveFlag" => 1,
"FileTimestamp" => time(),
);
return array(true , $file_item);
}
else
{
return array(false,"try to download[$http_url] to local[$save_file_path] res:". var_export($download_info,true));
}
}
保存web文件
最新推荐文章于 2022-06-06 09:46:46 发布