First open the Zendstudio Editor: directly on the code:
? 1234567891011121314151617181920212223 0) {$filename = $save _path. ‘/‘ . Uniqid (). '. jpg '; $handle = fopen ($filename, ' w+ '); Fwrite ($handle, $postdata); Fclose ($handle); if (Is_file ($filename)) {echo ' image data save Successed,file: '. $filename; exit ();} else {die (' image upload error! ' ); }} else {die (' Image data not detected! ');}
? 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 0) {switch ($FILES [' Filedata '] [' ERROR ']) {Case 1: $error _log = ' The file was bigger than this PHP installation allows '; "Case 2: $error _log = ' The file is Bigger than this form allows '; Break Case 3: $error _log = ' Only part of the file is uploaded '; Break Case 4: $error _log = ' No file ' is uploaded '; Break Default:break; } die (' Upload error: '. $error _log); } else {$img _data = $files[' Filedata ' [' tmp_name ']; $size = getimagesize ($img _data); $file _type = $size [' MIME ']; if (!in_array ($file _type, Array (' image/jpg ', ' image/jpeg ', ' image/pjpeg ', ' image/png ', ' image/gif '))) {$error _log = ' Only allow Jpg,png,gif '; Die (' Upload error: '. $error _log); } switch ($file _type) {case ' image/jpg ': Case ' image/jpeg ': Case ' image/pjpeg ': $extension = ' jpg '; /png ': $extension = ' png '; Break Case ' image/gif ': $extension = ' gif '; Break }} if (!is_file ($img _data)) {die (' image upload error! ');}//Picture save path, default saved in the directory where the code is located (can modify save path according to actual needs) $save _path = DirName (FILE); $uinqid = Uniqid (); $filename = $save _path. ‘/‘ . $uinqid. ‘.‘ . $extension; $result = Move_uploaded_file ($img _data, $filename); if (! $result | |!is_file ($filename)) {die (' image upload error! ');} echo ' Image data save Successed,file: '. $filename; Exit ();
Note: The bull view provides two upload interfaces for testing
One is the octet-stream way to upload, the address is: http://imgkaka.meitu.com/xiuxiu_web_pic_save.php
The other is multipart/form-data way to upload, the address is: http://web.upload.meitu.com/image_upload.php
Table sole name is called "Upload_file".
Bullish View Web open platform---php form upload code sharing