月度归档:2015 年六月

imagecopyresized和imagecopyresampled的区别

imagecopyresized和imagecopyresampled都是拷贝部分图像并调整大小,但是这两个函数有一个很大的区别,就是imagecopyresized生成的图像不如imagecopyresampled清晰,但是imagecopyresized生成的速度要比imagecopyresampled快,图片要比imagecopyresampled小。

PHP实现下载文件

$fileName = "text.pdf";
$file = fopen ($fileName, "r" );
//输入文件标签
Header ("Content-type: application/octet-stream");
Header ("Accept-Ranges: bytes");
Header ("Accept-Length: " . filesize ($fileName));
Header ("Content-Disposition: attachment; filename=" . time() . ".pdf");
//输出文件内容
//读取文件内容并直接输出到浏览器
echo fread ($file, filesize ($fileName));
fclose ($file);

 

ubuntu运行locale命令报错

报错如下:

root@AY1211110910427107334:~# locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE=zh_CN.UTF-8
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

解决方案:

sudo locale-gen zh_CN.UTF-8
sudo dpkg-reconfigure locales

如果上面命令还是提示失败,还一下语言。比如:

sudo locale-gen en_US.UTF-8
sudo dpkg-reconfigure locales