Beispiel #1
0
<?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();
}
Beispiel #2
0
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;
Beispiel #3
0
$data = $goods->_autoFill($data);
//自动填充
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);
<?php
/*
@Decription:文件上传类测试
@Author:GongBiao
@Date:2015/06/26
*/
header('Content-Type:text/html; charset=utf-8');

define('ACC', ture);

require('include/init.php');
require(ROOT . 'tools/UpTool.class.php');

$uptool = new UpTool();
$uptool->setSize(4);
$uptool->setExt('doc'); //追加doc格式
$uptool->setExt('txt'); //追加txt格式

if($res = $uptool->up('pic')){
	echo 'Ok,文件上传成功了呼~';
}else{
	echo '文件上传失败咯!<br />';
	echo $uptool->getError();

}

echo '<h3>程序运行完成!</h3>';

?>
Beispiel #5
0
<?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 '失败';
}