PHP Download Page Processing code-PHP source code

Source: Internet
Author: User
Tags php download
Processing code on the PHP download page Processing code on the PHP download page

Function get_extension ($ file) {return substr (strrchr ($ file ,'. '), 1);} function get_name ($ path) {return substr (strrchr ($ path,'/'), 1);} function getImage ($ url, $ fileName = "") {$ fbufsize = 8096; $ ext = get_extension ($ url); $ fileName = get_name ($ url ); $ type = array ('GIF' => 'image/GIF', 'jpeg '=> 'image/jpeg', 'jpg '=> 'image/jpeg ', 'jpe' => 'image/jpeg ', 'PNG' => 'image/png ',); $ imgType = isset ($ Type [$ ext])? $ Type [$ ext]: die ("type mismatch"); header ('content-Description: File Transfer '); header ('expires: 0 '); header ('cache-Control: must-revalidate, post-check = 0, pre-check = 0'); header ('pragma: public '); header ("Content-type :". $ imgType); header ("Content-Transfer-Encoding: binary"); header ('content-Disposition: attachment; filename = "'. $ fileName. '"'); header (" Content-Length :". getimagesize ($ url ). "\ n"); $ fp = fopen ($ ur L, "r"); while (! Feof ($ fp) {print (fread ($ fp, $ fbufsize); flush (); ob_flush () ;}fclose ($ fp); exit ;} getImage (" http://snowcoal.com/IMAGES_6930/201407/1405910422162.jpg ");

The above is the content of the processing code on the PHP download page. For more information, see The PHP Chinese website (www.php1.cn )!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.