function upload(&$bhv) { $uploaddb = array(); foreach ($_FILES as $key => $value) { if (!PwUpload::if_uploaded_file($value['tmp_name']) || !$bhv->allowType($key)) { continue; } $atc_attachment = $value['tmp_name']; $upload = PwUpload::initCurrUpload($key, $value); if (empty($upload['ext']) || !isset($bhv->ftype[$upload['ext']])) { showUploadMsg('upload_type_error'); } if ($upload['size'] < 1 || $upload['size'] > $bhv->ftype[$upload['ext']] * 1024) { $GLOBALS['atc_attachment_name'] = $upload['name']; $GLOBALS['oversize'] = $bhv->ftype[$upload['ext']]; showUploadMsg($upload['size'] < 1 ? 'upload_size_0' : 'upload_size_error'); } list($filename, $savedir) = $bhv->getFilePath($upload); $source = PwUpload::savePath($bhv->ifftp, $filename, $savedir); if (!PwUpload::postupload($atc_attachment, $source)) { showUploadMsg('upload_error'); } clearstatcache(); $upload['size'] = ceil(filesize($source) / 1024); $upload['fileuploadurl'] = $savedir . $filename; PwUpload::operateAttach($source, $filename, $savedir, $upload, $bhv); $uploaddb[] = $upload; } return $bhv->update($uploaddb); }
function upload(&$bhv) { $uploaddb = array(); foreach ($_FILES as $key => $value) { if (!PwUpload::if_uploaded_file($value['tmp_name']) || !$bhv->allowType($key)) { continue; } $atc_attachment = $value['tmp_name']; $upload = PwUpload::initCurrUpload($key, $value); if (empty($upload['ext']) || !isset($bhv->ftype[$upload['ext']])) { uploadmsg('upload_type_error'); } if ($upload['size'] < 1 || $upload['size'] > $bhv->ftype[$upload['ext']] * 1024) { $GLOBALS['atc_attachment_name'] = $upload['name']; $GLOBALS['oversize'] = $bhv->ftype[$upload['ext']]; uploadmsg($upload['size'] < 1 ? 'upload_size_0' : 'upload_size_error'); } list($filename, $savedir, $thumbname, $thumbdir) = $bhv->getFilePath($upload); $upload['fileuploadurl'] = $savedir . $filename; $source = PwUpload::savePath($bhv->ifftp, $filename, $savedir); $thumburl = PwUpload::savePath($bhv->ifftp, $thumbname, $thumbdir, 'thumb_'); if (!PwUpload::postupload($atc_attachment, $source)) { uploadmsg('upload_error'); } $upload['size'] = ceil(filesize($source) / 1024); if (in_array($upload['ext'], array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'swf'))) { require_once R_P . 'require/imgfunc.php'; if (!($img_size = GetImgSize($source, $upload['ext']))) { P_unlink($source); uploadmsg('upload_content_error'); } if ($upload['ext'] != 'swf') { if ($bhv->allowThumb()) { $thumbsize = PwUpload::makeThumb($source, $thumburl, $bhv->getThumbSize(), $upload['ifthumb']); } if ($bhv->allowWaterMark()) { PwUpload::waterMark($source, $upload['ext'], $img_size); $upload['ifthumb'] && PwUpload::waterMark($thumburl, $upload['ext']); } $upload['type'] = 'img'; } } elseif ($upload['ext'] == 'txt') { if (preg_match('/(onload|submit|post|form)/i', readover($source))) { P_unlink($source); uploadmsg('upload_content_error'); } $upload['type'] = 'txt'; } if ($bhv->ifftp) { PwUpload::movetoftp($source, $upload['fileuploadurl']); $upload['ifthumb'] && PwUpload::movetoftp($thumburl, $thumbdir . $thumbname); } $uploaddb[] = $upload; } $bhv->update($uploaddb); }
function upload(&$bhv) { $uploaddb = array(); $count = $size = 0; foreach ($_FILES as $key => $value) { if (!PwUpload::if_uploaded_file($value['tmp_name']) || !$bhv->allowType($key)) { continue; } $atc_attachment = $value['tmp_name']; $upload = PwUpload::initCurrUpload($key, $value); if (empty($upload['ext']) || !isset($bhv->ftype[$upload['ext']])) { $errCode = '上传附件类型错误!'; return $errCode; } if ($upload['size'] < 1 || $upload['size'] > $bhv->ftype[$upload['ext']] * 1024) { $GLOBALS['atc_attachment_name'] = $upload['name']; $GLOBALS['oversize'] = $bhv->ftype[$upload['ext']]; $errCode = '上传附件太小或超出' . $bhv->ftype[$upload['ext']] . 'KB!'; return $errCode; } list($filename, $savedir) = $bhv->getFilePath($upload); $source = PwUpload::savePath($bhv->ifftp, $filename, $savedir); if (!PwUpload::postupload($atc_attachment, $source)) { $errCode = '上传附件出错'; return $errCode; } clearstatcache(); $upload['size'] = ceil(filesize($source) / 1024); $upload['fileuploadurl'] = $savedir . $filename; PwUpload::operateAttach($source, $filename, $savedir, $upload, $bhv); $count++; $size += $upload['size'] * 1024; $uploaddb[] = $upload; } $bhv->update($uploaddb); return 'success'; }