2, php code (file upload, name the file with timestamp, save file path in session)
-
- /**
- *Mwbe Version1.0
- *-----------------------------------------------
- *Copy 2013-2014 ylt
- *Web: communicate
- *-----------------------------------------------
- *Author: tao *Data: 2014-7-22
- */
- header("Content-Type:text/html;charset=utf-8");
- //step 1 Use $_FILES['pic ']["error"] Check for errors
- if(isset($_GET["action"])=="img"){
- if($_FILES["img"]["error"] > 0){
- switch($_FILES["img"]["error"]) {
- case 1:
- echo "";
- break;
- case 3:
- echo "";
- break;
- case 4:
- echo "";
- break;
- default:
- echo "";
- }
- exit;
- }
- $maxsize=2000000; //50k
- //step 2 Use $_FILES["pic"]["size"] to limit the size unit in bytes 2M=2000000
- if($_FILES["img"]["size"] > $maxsize ) {
- echo "";
- exit;
- }
- //step 3 Use $_FILES["pic"]["type"] or the file extension Name restriction type MIME image/gif image/png gif png jpg
- /* list($dl, $xl) = explode("/", $_FILES["pic"]["type"]);
- if($dl !="image"){
- echo "Please upload an image, other types of files are not allowed";
- exit;
- }
- */ bbs.it-home.org
- $allowtype=array("png", "gif ", "jpg", "jpeg");
- $arr=explode(".", $_FILES["img"]["name"]);
- $hz=$arr[count($arr)-1] ;
- if(!in_array($hz, $allowtype)){
- echo "" ;
- session_start();
- $_SESSION['images'] = $fileimgweb.$randname;
- }else{
- echo "";
- }
- }else{
- echo"
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31
|