在数组中$_FILES
一切都很完美。我该如何压缩文件?变量$Buffer
以base64格式返回。
这是我的代码:
$url = 'destination1.jpg';
$filename = compress_image($_FILES["uploadfile"]["tmp_name"], $url, 80);
$buffer = file_get_contents($url); /* Force download dialog... */
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download"); /* Don't allow caching... */
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); /* Set data type, size and filename */
header("Content-Type: application/octet-stream");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . strlen($buffer));
header("Content-Disposition: attachment; filename=$url"); /* Send our file... */
$buffer;
compress_image函数如下:
function compress_image($source_url, $destination_url, $quality)
{
$info = getimagesize($source_url);
if ($info['mime'] == 'image/jpeg') $image =
imagecreatefromjpeg($source_url);
elseif ($info['mime'] == 'image/gif') $image =
imagecreatefromgif($source_url);
imagejpeg($image, $destination_url, $quality);
// echo $destination_url;exit();
return $destination_url;
}
请帮帮我。