<?php define('ACC', true); require "./include/init.php"; require ROOT . "tool/UpTool.class.php"; /*** * @auther:zhangyang */ $uptool = new UpTool(); if ($res = $uptool->up('pic')) { echo 'OK<br />'; echo '文件存放在:' . $res; } else { echo 'FAIL<br />'; echo $uptool->getError(); }
//自动填充 if (empty($data['goods_sn'])) { $data['goods_sn'] = $goods->createSn(); } /** * 自动验证 */ if (!$goods->_validate($data)) { echo "<script>alert('表单填写错误," . implode('', $goods->getError()) . "');history.back()</script>"; exit; } /** * 上传图片 */ $uptool = new UpTool(); $ori_img = $uptool->up('ori_img'); if ($ori_img) { $data['ori_img'] = $ori_img; /** * 如果上传成功 则生成缩略图 300*400 * 再生成浏览时的小图 160*220 */ $ori_img = ROOT . $ori_img; $goods_image = dirname($ori_img) . '/goods_' . basename($ori_img); if (ImageTool::thumb($ori_img, $goods_image, 300, 400)) { $data['goods_img'] = str_replace(ROOT, '', $goods_image); } $thumb_image = dirname($ori_img) . '/thumb_' . basename($ori_img); if (ImageTool::thumb($ori_img, $thumb_image, 300, 400)) { $data['thumb_img'] = str_replace(ROOT, '', $thumb_image); }
Uploadify Copyright (c) 2012 Reactive Apps, Ronnie Garcia Released under the MIT License <http://www.opensource.org/licenses/mit-license.php> */ // Define a destination /*$targetFolder = '/uploads'; // Relative to the root $timestamp = time(); $verifyToken = md5('unique_salt' . $timestamp); if (!empty($_FILES) || $_POST['token'] == $verifyToken) { $tempFile = $_FILES['Filedata']['tmp_name']; $targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder; $targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name']; // Validate the file type $fileTypes = array('jpg','jpeg','gif','png'); // File extensions $fileParts = pathinfo($_FILES['Filedata']['name']); if (in_array($fileParts['extension'],$fileTypes)) { move_uploaded_file($tempFile,$targetFile); echo '1'; } else { echo 'Invalid file type.'; } }*/ define('ACC', true); require './include/init.php'; $data = array(); $uptool = new UpTool(); $ori_img = $uptool->up('Filedata'); echo $ori_img;
<?php header('Content-type:text/html;charset=utf-8'); include './UpTool.class.php'; $up = new UpTool(); // $up->savePath = './uploads/'; $rs = $up->up('pic'); echo $rs; if ($rs) { echo '成功'; } else { echo '失败'; }