PHP--File upload download

Source: Internet
Author: User

-----026-upload.php-----

1<! DOCTYPE html>234<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">5<title> Upload Images </title>67<body align= "Left" >89<p style= "font-size:16pt" >Ten<form method= "POST" enctype= "Multipart/form-data" style= "border:1px solid; width:400px "> OneUpload Image: <input type= "file" name= ' file ' id= "file" ><br/> APut here: <input type= "text" name= "TXT" ><br/> -<input type= "Submit" name= "Upload" value= "Start uploading" > -</form> the<?PHP -     foreach($_post  as $key=$value) { -         Echo $key, "= =",$value, "<br/>"; -     } +     if(isset($_post["Upload"])){ -         Echo"It's ready!!" <br/> "; +         Echo $_files[' File '] [' Type ']; A         if($_files[' File '] [' type '] = = "Image/pjpeg") at         { -             Echo"File name:",$_files[' File '] [' name '], ' <br/> '; -             Echo"File type:",$_files[' File '] [' type '], ' <br/> '; -             Echo"File Size:",$_files[' File '] [' Size '], ' <br/> '; -             Echo"Copy Name:",$_files[' File '] [' Tmp_name '], ' <br/> '; -             Move_uploaded_file($_files[' File '] [' Tmp_name '], "uploads/".$_files[' File '] [' Name ']); in             Echo"File stored in:", "uploads/".$_files[' File '] [' name '], ' <br/> '; -             Echo"$_files[' File '] [' Name '], "width=300>"; to  +         } -     } the?> *</p> $</body>Panax Notoginseng

-----027-download.php-----

1<! DOCTYPE html>234<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">5<title> Download Files </title>67<body>8<fieldset>9<legend> File Download </legend>Ten One<a href= "? action=download" > download file to local <br/></a> A<?PHP -     $file _name= "Bietaichang.jpg"; -     $file _dir= "uploads/"; the     Echo"File Size:",filesize($file _dir.$file _name), "\ n"; -     if(isset($_get["Action"])) -     { -         $file=fopen($file _dir.$file _name, "RB"); +         Header("Content-type:application/octet-stream"); -         Header("Accept-ranges:bytes"); +         Header("Accept-length:".)filesize($file _dir.$file _name)); A         Header("Content-disposition:attachment; Filename= ".$file _name); at         Echo fread($file,filesize($file _dir.$file _name)); -         fclose($file); -         Exit; -     } -?> -</fieldset> in</body> -

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.