jqueryphp多资料上传
时间:2021-07-01 10:21:17
帮助过:4人阅读
jquery php多文件上传
多文件上传
演示?
index.php
PHP Code- "uploaderform">??
- ??
- ??
- "uploadResults">??
- ????"center"?style="margin:20px;">"#"?id="ShowForm">打开/隐藏?表单??
- ????"output">??
- ??
js文件
JavaScript Code- ???
?uoload.php
?
PHP Code- "center">"index.php">Go?Back?To?Upload?Form??
- ??
- ??
- ??
- ???
- $ThumbSquareSize????????=?200;???
- $BigImageMaxSize????????=?500;???
- $ThumbPrefix????????????=?"thumb_";???
- $DestinationDirectory???=?'../upload/';???
- $Quality????????????????=?90;??
- ??
- ??
- ??
- foreach($_FILES?as?$file)??
- {??
- ??
- $ImageName??????=?$file['name'];??
- $ImageSize??????=?$file['size'];??
- $TempSrc????????=?$file['tmp_name'];??
- $ImageType??????=?$file['type'];??
- ??
- ??
- if?(is_array($ImageName))???
- {??
- ????$c?=?count($ImageName);??
- ??????
- ????echo??';??
- ??????
- ????for?($i=0;?$i?$c;?$i++)??
- ????{??
- ????????$processImage???????????=?true;???
- ????????$RandomNumber???????????=?rand(0,?9999999999);????
- ??????????
- ????????if(!isset($ImageName[$i])?||?!is_uploaded_file($TempSrc[$i]))??
- ????????{??
- ????????????echo?'Error?occurred?while?trying?to?process?'.$ImageName[$i].',?may?be?file?too?big!';???
- ????????}??
- ????????else??
- ????????{??
- ??????????????
- ????????????switch(strtolower($ImageType[$i]))??
- ????????????{??
- ????????????????case?'image/png':??
- ????????????????????$CreatedImage?=?imagecreatefrompng($TempSrc[$i]);??
- ????????????????????break;??
- ????????????????case?'image/gif':??
- ????????????????????$CreatedImage?=?imagecreatefromgif($TempSrc[$i]);??
- ????????????????????break;??
- ????????????????case?'image/jpeg':??
- ????????????????case?'image/pjpeg':??
- ????????????????????$CreatedImage?=?imagecreatefromjpeg($TempSrc[$i]);??
- ????????????????????break;??
- ????????????????default:??
- ????????????????????$processImage?=?false;???
- ????????????}??
- ??????????????
- ????????????list($CurWidth,$CurHeight)=getimagesize($TempSrc[$i]);??
- ??
- ??????????????
- ????????????$ImageExt?=?substr($ImageName[$i],?strrpos($ImageName[$i],?'.'));??
- ????????????$ImageExt?=?str_replace('.','',$ImageExt);??
- ??????
- ??????????????
- ????????????$NewImageName?=?$RandomNumber.'.'.$ImageExt;??
- ??
- ??????????????
- ????????????$thumb_DestRandImageName????=?$DestinationDirectory.$ThumbPrefix.$NewImageName;???
- ????????????$DestRandImageName??????????=?$DestinationDirectory.$NewImageName;???
- ??
- ????????????