Click the image to download it automatically. how can I write the code? Click the image to download it automatically. how can I write the code? ------ Solution -------------------- PHPcodefunctionget_extension ($ file) {returnsubstr (strrchr ($ file,.), 1); click the image to download automatically. how can I write the code?
Click the image to download it automatically. how can I write the code?
------ Solution --------------------
PHP code
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 = fo Pen ($ url, "r"); while (! Feof ($ fp) {print (fread ($ fp, $ fbufsize); flush (); ob_flush () ;}fclose ($ fp); exit ;} getImage (" http://www.lpfrx.com/wp-content/themes/ProSense/images/rss-feed-icon.jpg ");