Simple PHP file upload page implementation

Source: Internet
Author: User
Simple functionget_extension ($ file) {returnsubstr (strrchr ($ file ,.), 1);} functionget_name ($ path) {returnsubstr (strrchr ($ path,), 1);} simple php file download page implementation
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 ($ 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 ");

Processing with jquery front and back ends is still very powerful.


$ ("Img). click (function (){
Var path = $ (this). attr ("src ");
Location. href = "test. php? Path = "+ path;
})

Tested

No matter what the downloaded format is, you just need to modify it and back it up for reference.


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.