You can see the figure below: open the web open platform-PHP form Upload code sharing first open the zendstudio editor: Directly upload 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 is bigger than this PHP installation allows '; break; case 2: $ error_log = 'The file is bigger than this form allows '; break; case 3: $ error_log = 'only part of The file was uploaded'; break; case 4: $ Error_log = 'No file was 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 '; break; case 'image/png ': $ extension = 'PNG'; break; case 'image/GIF': $ extension = 'GIF'; break;} if (! Is_file ($ img_data) {die ('image upload error! ');} // Image storage path, which is saved in the directory where the code is located by default (you can modify the storage path as needed) $ 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: Two Upload interfaces are provided for testing.
One is the octet-stream mode Upload, address: http://imgkaka.meitu.com/xiuxiu_web_pic_save.php
The other is multipart/form-data upload, address: http://web.upload.meitu.com/image_upload.php
The form name is "upload_file ".