/** * 上传单个或多个文件 * @param int $type * $type为0:上传图片 * $type为1:上传视频 */ function uploadmulti($type) { // print_r($_FILES);die; $files = getFiles(); $path = dirname(dirname(__FILE__)); //获取upload_image的上层目录的绝对路径 if ($type == 0) { $uploadPath = $path . '/upload_image'; } else { $uploadPath = $path . '/upload_video'; } foreach ($files as $fileInfo) { $upload = new upload($fileInfo, $uploadPath, false); $dest = $upload->uploadFile(); $uploadFiles[] = $dest; } $uploadFiles = array_values(array_filter($uploadFiles)); return $uploadFiles; }
/** * 上传单个或多个文件 * @param int $type * $type为0:上传图片 * $type为1:上传视频 * $type为2:上传缩略图 */ function uploadmulti($fileName, $type) { // print_r($_FILES);die; $files = getFiles(); if ($type == 0) { $uploadPath = '../../../common/upload_image'; } elseif ($type == 1) { $uploadPath = '../../../common/upload_video'; } else { $uploadPath = '../../../common/upload_thumb'; } foreach ($files as $fileInfo) { $upload = new upload($fileName, $fileInfo, $uploadPath, false); $dest = $upload->uploadFile(); $uploadFiles[] = $dest; } $uploadFiles = array_values(array_filter($uploadFiles)); return $uploadFiles; }
<?php header('content-type:text/html;charset=utf-8'); require_once 'upload.class.php'; //$upload = new upload('myFile1'); $upload = new upload('myFile1', 'test'); $dest = $upload->uploadFile(); echo $dest;
unset($rs); $page_nav = multi($total_num, $perpage, $pg, urr("mydisk", "item=profile&action={$action}")); require_once template_echo('profile', $user_tpl_dir); break; case 'invite': $invite_url = $settings['invite_register_encode'] ? $settings['phpdisk_url'] . urr("account", "action=register&" . pd_encode('uid=' . $pd_uid)) : $settings['phpdisk_url'] . urr("account", 'action=register&uid=' . $pd_uid); // my downlines $my_downlines = @$db->result_first("select count(*) from {$tpf}buddys where userid='{$pd_uid}'"); require_once template_echo('profile', $user_tpl_dir); break; case 'application_teacher': if ($task == 'save_image') { //增加保存图片的代码 require PHPDISK_ROOT . 'includes/class/upload.class.php'; $upload = new upload('file', APPLICATION_MATERIALS_DIR); $fileName = $upload->uploadFile(); //清除显示 ob_get_clean(); echo json_encode(array('status' => 'ok', 'data' => array('filename' => basename($fileName)), 'msg' => '成功上传文件')); exit; } elseif ($task == 'application_add') { //检查是否存在提交的信息 $application_one = get_application_teacher_status(); if ($application_one) { $sysmsg = array('不能重复申请,请先取消当前教师申请'); redirect('back', $sysmsg); exit; } //申请提交的代码 form_auth(gpc('formhash', 'P', ''), formhash()); $user_name = gpc('user_name');
<input type="file" name="myLogo" accept="image/jpeg,image/gif,image/png"/> <br /> 请选择你要上传的excel文件: <input type="file" name="myExcel" accept="application/msexcel"/> <input type="submit" value="上传信息" /> <br /> </form> </center> </body> </html> <?php header('content-type:text/html;charset=utf-8'); require_once '../libs/upload.class.php'; require_once '../libs/upload_img.class.php'; require_once '../include.php'; if (!empty($_POST["bookName"])) { //上传logo $uploadimg = new upload_img("myLogo", "../logo"); $destexcel_img = $uploadimg->uploadFile(); // echo $destexcel_img; //录入电话簿数据库 $phonebook = array("name" => $_POST["bookName"], "intr" => $_POST["intr"], 'logo' => $destexcel_img); insert('phonebook', $phonebook); // $sql = "INSERT INTO phonebook (name,intr,logo) VALUES('".$_POST["bookName"]."','".$_POST["intr"]."','".$destexcel_img."')"; // echo $sql.'<br />'; // $res = mysql_query($sql); //上传excel表并解析 $uploadexcel = new upload('myExcel', '../excels', '5242880', array('xlsx', 'xls')); $destexcel = $uploadexcel->uploadFile(mysql_insert_id()); // echo $destexcel; }