本文整理汇总了PHP中FileUpload::upload方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUpload::upload方法的具体用法?PHP FileUpload::upload怎么用?PHP FileUpload::upload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUpload
的用法示例。
在下文中一共展示了FileUpload::upload方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editorupload
public function editorupload()
{
$CRUD_AUTH = $this->session->userdata('CRUD_AUTH');
if (empty($CRUD_AUTH)) {
exit;
}
if (isset($_GET['CKEditorFuncNum'])) {
require FCPATH . '/application/third_party/scrud/class/FileUpload.php';
$msg = '';
// Will be returned empty if no problems
$callback = $_GET['CKEditorFuncNum'];
// Tells CKeditor which function you are executing
$fileUpload = new FileUpload();
$fileUpload->uploadDir = __IMAGE_UPLOAD_REAL_PATH__;
$fileUpload->extensions = array('.bmp', '.jpeg', '.jpg', '.png', '.gif');
$fileUpload->tmpFileName = $_FILES['upload']['tmp_name'];
$fileUpload->fileName = $_FILES['upload']['name'];
$fileUpload->httpError = $_FILES['upload']['error'];
if ($fileUpload->upload()) {
$image_url = __MEDIA_PATH__ . "images/" . $fileUpload->newFileName;
}
$error = $fileUpload->getMessage();
if (!empty($error)) {
$msg = 'error : ' . implode("\n", $error);
}
$output = '<script type="text/javascript">window.parent.CKEDITOR.tools.callFunction(' . $callback . ', "' . $image_url . '","' . $msg . '");</script>';
echo $output;
}
}
示例2: upload
function upload()
{
$path = "./uploads/";
//设置图片上传路径
$up = new FileUpload($path);
//创建文件上传类对象
if ($up->upload('pic')) {
//上传图片
$filename = $up->getFileName();
//获取上传后的图片名
$img = new Image($path);
//创建图像处理类对象
$img->thumb($filename, 300, 300, "");
//将上传的图片都缩放至在300X300以内
$img->thumb($filename, 80, 80, "icon_");
//缩放一个80x80的图标,使用icon_作前缀
$img->watermark($filename, "logo.gif", 5, "");
//为上传的图片加上图片水印
return array(true, $filename);
//如果成功返回成功状态和图片名称
} else {
return array(false, $up->getErrorMsg());
//如果失败返回失败状态和错误消息
}
}
示例3: editCuadro
private static function editCuadro($gestor, $sesion)
{
$obra = new Obra();
$obra->read();
$pkID = Request::post("pkID");
$nombre = Request::post("nombre");
$email = Request::post('email');
$usuario = $sesion->getUser();
$obra->setId_usuario($usuario);
/*Subir fotografia*/
$subir = new FileUpload("nuevaImagen");
$subir->setDestino("../../controlUsuario/cuadros/{$usuario}/");
$subir->setTamaño(100000000);
$subir->setNombre($nombre);
$subir->setPolitica(FileUpload::REEMPLAZAR);
if ($subir->upload()) {
echo 'Archivo subido con éxito';
$obra->setImagen($nombre . "." . $subir->getExtension());
} else {
echo 'Archivo no subido';
}
$obra->setImagen($nombre . "." . $subir->getExtension());
$r = $gestor->set($obra, $pkID);
echo $r;
//header("Location:index.php?op=edit&r=$r");
}
示例4: FileUpload
function m_updateCompInfo()
{
if (!isset($this->request['bill_state_id']) || empty($this->request['bill_state_id'])) {
$this->request['bill_state_id'] = "";
} else {
$this->request['bill_state'] = "";
}
#FILE UPLOADING START
if ($this->libFunc->checkImageUpload("image1") && $_FILES["image1"]["tmp_name"] != "") {
$fileUpload = new FileUpload();
$fileUpload->source = $_FILES["image1"]["tmp_name"];
$fileUpload->target = $this->imagePath . "company/" . $_FILES["image1"]["name"];
$newName1 = $fileUpload->upload();
$fileUpload->resampleImage($this->imagePath . "company/" . $newName1, 250, 250, 100);
// [/DRK]
if ($newName1 != false) {
$image1 = $newName1;
}
} else {
$this->obDb->query = "SELECT vLogo FROM " . COMPANYSETTINGS;
$logo = $this->obDb->fetchQuery();
$image1 = $logo[0]->vLogo;
}
#INSERTING COMPANY DETAILS
$this->obDb->query = "UPDATE " . COMPANYSETTINGS . " SET \n\t\tvCname ='" . $this->libFunc->m_addToDB($this->request['storeName']) . "',\n\t\tvAddress ='" . $this->libFunc->m_addToDB($this->request['storeAddress']) . "',\n\t\tvCity ='" . $this->libFunc->m_addToDB($this->request['storeCity']) . "',\n\t\tvState='" . $this->libFunc->m_addToDB($this->request['bill_state_id']) . "',\n\t\tvStateName='" . $this->libFunc->m_addToDB($this->request['bill_state']) . "',\n\t\tvCountry='" . $this->libFunc->m_addToDB($this->request['bill_country_id']) . "',\n\t\tvZip='" . $this->libFunc->m_addToDB($this->request['storeZip']) . "',\n\t\tvFax ='" . $this->libFunc->m_addToDB($this->request['storeFax']) . "',\n\t\tvPhone ='" . $this->libFunc->m_addToDB($this->request['storePhone']) . "',\n\t\tvFreePhone ='" . $this->libFunc->m_addToDB($this->request['storeTollFree']) . "',\n\t\tvVatNumber ='" . $this->libFunc->m_addToDB($this->request['vatNumber']) . "',\n\t\tvRNumber ='" . $this->libFunc->m_addToDB($this->request['companyNumber']) . "',\n\t\tvSlogan ='" . $this->libFunc->m_addToDB($this->request['companySlogan']) . "',\n\t\tvLogo ='" . $image1 . "'";
$this->obDb->updateQuery();
$this->libFunc->m_mosRedirect(SITE_URL . "admin/adminindex.php?action=settings.company&msg=1");
}
示例5: preform
public function preform()
{
$uploadFile = new FileUpload();
$uploadFile->set("maxsize", 2000000);
$uploadFile->set("allowtype", array("gif", "png", "jpg", "jpeg"));
$uploadFile->set("israndname", true);
if ($this->params['safe']['type'] == "addArticle") {
$path = "../uploadfile/article/" . $this->params['safe']['fenlei_id'] . "/";
$uploadFile->set("path", $path);
if ($uploadFile->upload('fm_img')) {
$data = array('uid' => 1, 'title' => $this->params['safe']['title'], 'contents' => $this->params['safe']['contents'], 'fenlei_id' => $this->params['safe']['fenlei_id'], 'fm_img' => $path . $uploadFile->getFileName(), 'time' => time());
$DaoArticle = new DaoArticle();
$DaoArticle->insertArticle($data);
} else {
//获取上传失败以后的错误提示
throw new Exception('error_file_upload', $uploadFile->getErrorMsg());
}
} elseif ($this->params['safe']['type'] == "addUser") {
$path = "../uploadfile/user_img/" . $this->params['safe']['user_name'] . "/";
$uploadFile->set("path", $path);
if ($uploadFile->upload('user_img')) {
$data = array('user_name' => $this->params['safe']['user_name'], 'user_nickname' => $this->params['safe']['user_nickname'], 'user_password' => md5($this->params['safe']['password']), 'user_qm' => "这家伙还没写签名呢!", 'user_img' => $path . $uploadFile->getFileName(), 'user_inTime' => time());
$DaoUser = new DaoUser();
$DaoUser->addUser($data);
} else {
//获取上传失败以后的错误提示
throw new Exception('error_file_upload', $uploadFile->getErrorMsg());
}
} elseif ($this->params['safe']['type'] == "addfenlei") {
$path = "../uploadfile/Fenlei/";
$uploadFile->set("path", $path);
if ($uploadFile->upload('fenlei_img')) {
$data = array('name' => $this->params['safe']['name'], 'time' => time(), 'fenlei_img' => $path . $uploadFile->getFileName());
$DaoFenlei = new DaoFenlei();
$DaoFenlei->addFenlei($data);
}
}
}
示例6: FileUpload
function m_uploadImage()
{
$fileUpload = new FileUpload();
$libFunc = new c_libFunctions();
$this->obDb->query = "select iVendorid_PK,vImage from " . SUPPLIERS . " where iVendorid_PK = " . $this->request['id'];
$row_code = $this->obDb->fetchQuery();
if ($this->libFunc->checkImageUpload("image")) {
$fileUpload->source = $_FILES["image"]["tmp_name"];
$fileUpload->target = $this->imagePath . "suppliers/" . $_FILES["image"]["name"];
$newName1 = $fileUpload->upload();
if ($newName1 != false) {
$image = $newName1;
}
if (!empty($row_code[0]->vImage)) {
$fileUpload->deleteFile($this->imagePath . "suppliers/" . $row_code[0]->vImage);
}
$imagename = "image";
} else {
$image = $row_code[0]->vImage;
}
$this->obDb->query = "UPDATE " . SUPPLIERS . " SET `vImage`='{$image}', `tmEditDate`='" . time() . "', `iAdminUser` ='" . $_SESSION['uid'] . "' where iVendorid_PK ='" . $this->request['id'] . "'";
$this->obDb->updateQuery();
$this->libFunc->m_mosRedirect(SITE_URL . "user/adminindex.php?action=supplier.uploadForm&status=1&id=" . $this->request['id']);
}
示例7: Session
<?php
require '../clases/AutoCarga.php';
$sesion = new Session();
$archivo = Request::post("archivo");
$nombre = Request::post("nombre");
var_dump($nombre);
var_dump($archivo);
$artista = $sesion->getUser();
$carpeta = "../images/" . $artista->getEmail();
$subir = new FileUpload("archivo");
if (!file_exists($carpeta)) {
mkdir($carpeta, 0777);
}
$subir->upload();
//$sesion->sendRedirect("index.php");
示例8: FileUpload
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$uploader = new FileUpload();
//用于断点续传,验证指定分块是否已经存在,避免重复上传
if (isset($_POST['status'])) {
if ($_POST['status'] == 'chunkCheck') {
$target = '../uploads/' . $_POST['name'] . '/' . $_POST['chunkIndex'];
if (file_exists($target) && filesize($target) == $_POST['size']) {
die('{"ifExist":1}');
}
die('{"ifExist":0}');
} elseif ($_POST['status'] == 'md5Check') {
//todo 模拟持久层查询
$dataArr = array('b0201e4d41b2eeefc7d3d355a44c6f5a' => 'kazaff2.jpg');
if (isset($dataArr[$_POST['md5']])) {
die('{"ifExist":1, "path":"' . $dataArr[$_POST['md5']] . '"}');
}
die('{"ifExist":0}');
} elseif ($_POST['status'] == 'chunksMerge') {
if ($path = $uploader->chunksMerge($_POST['name'], $_POST['chunks'], $_POST['ext'])) {
//todo 把md5签名存入持久层,供未来的秒传验证
die('{"status":1, "path": "' . $path . '"}');
}
die('{"status":0');
}
}
if (($path = $uploader->upload('file', $_POST)) !== false) {
die('{"status":1, "path": "' . $path . '"}');
}
die('{"status":0}');
示例9: upload
function upload($path = '')
{
$path = $this->BaseUrl . '/' . trim($path, '/');
if (!is_dir($path)) {
$data['error'] = 'Folder ' . $path . ' does not exist.';
return $data;
}
$up = new FileUpload();
//设置属性(上传的位置, 大小, 类型, 名是是否要随机生成)
$up->set("path", $path);
$up->set("maxsize", 8 * 1024 * 1024);
if (!empty($this->allowType) && $this->allowType != '*') {
$up->set("allowtype", explode(',', $this->allowType));
}
$up->set("israndname", false);
if ($up->upload("upfile")) {
return $up->getFileName();
} else {
$data['error'] = $up->getErrorMsg();
}
/**/
return $data;
}
示例10: insertArt
private static function insertArt()
{
$sesion = new Session();
if ($sesion->isLogged()) {
$db = new DataBase();
$manager = new ManageArt($db);
$managerUser = new ManageUser($db);
$email = Request::post("email");
$title = Request::post("title");
$usuario = $managerUser->get($email);
$art = new Art();
$art->setEmail($email);
$art->setTitle($title);
$art->setCdate(date('Y-m-d G:i:s'));
$fecha = date('_Y_m_d_G_i_s');
$photo = new FileUpload("image");
if ($photo->getError() === false) {
$art->setImage("./resources/art/" . $usuario->getAlias() . $fecha . ".jpg");
$photo->setDestination("./resources/art/");
$photo->setName($usuario->getAlias() . $fecha);
$photo->upload();
}
$manager->insert($art);
$db->close();
}
self::viewProfile();
}
示例11: FileUpload
?>
<br/>
<div class="foto" id="fotopersonal"><img src="../images/<?php
echo $foto;
?>
.jpg" id='imagep'/></div><br/><br/>
<form method="post" action="#" enctype="multipart/form-data"/><br/><br/>
<input type="file" name="imagen" value="Editar imagen"/><br/><br/>
<input type="submit" name="enviar" value="Subir" class="enviar" />
</form>
<?php
$trozo = $usuario->getTrozo($em);
$fileUpload = new FileUpload($_FILES["imagen"]);
$fileUpload->setNombre($trozo);
$fileUpload->setDestino("../images/");
$fileUpload->upload();
?>
</div>
<div class="capafoto">
<h2 class="tb"> MI PERFIL</h2>
<table>
<form method="POST" action="../oauth/modificar.php">
<tr><td>Email:</td><td> <input type="text" name="email" value=" <?php
echo $usuario->getEmail();
?>
"/></td>
<tr><td>Alias:</td><td><?php
echo $em;
?>
示例12: FileUpload
function m_uploadImages()
{
$fileUpload = new FileUpload();
foreach ($_FILES["image"]["name"] as $key => $val) {
if ($_FILES["image"]["name"][$key] != "") {
$fileUpload->source = $_FILES["image"]["tmp_name"][$key];
$fileUpload->target = $this->imagePath . "options/" . $_FILES["image"]["name"][$key];
$image[] = $fileUpload->upload();
} else {
$image[] = 0;
}
}
return $image;
}
示例13: insertSet
private static function insertSet()
{
$bd = new BaseDatos();
$gestor_galeria = new ManageGallery($bd);
$sesion = new Session();
$artista = self::getArtist($sesion);
$descripcion = Request::post("descripcion");
$id = Request::post("id");
$file = new FileUpload("imagen");
var_dump($gestor_galeria->count());
$nombre = $artista->getGaleria() . "_" . ($gestor_galeria->count() + 1) . sha1($file->getNombre());
$file->setNombre($nombre);
$file->setDestino("../img/");
$file->setTamanio(52428800);
$file->getPolitica(FileUpload::RENOMBRAR);
$file->addTipo("gif");
$file->upload();
$imagen_ruta = "../img/" . $file->getNombre() . "." . $file->getExtension();
$gallery = new Gallery($id, 0, $imagen_ruta, $descripcion);
$r = $gestor_galeria->insert($gallery);
header("Location:?op=insert&r={$r}&action=read&do=View#section3");
}
示例14: Session
<?php
require 'clases/Request.php';
require 'clases/FileUpload.php';
require 'clases/Session.php';
require 'clases/Server.php';
$sesion = new Session();
$user = $sesion->get("usuario");
$usuario = Request::post("usuario1");
$categoria = Request::post("categoria1");
$cancion = new FileUpload("cancion");
$cancion->setDestino("canciones/");
$cancion->setNombre($user . "_" . $categoria . "_" . $cancion->getNombre());
$cancion->setPolitica(FileUpload::RENOMBRAR);
$cancion->upload();
$imagen = new FileUpload("imagen");
$imagen->setDestino("canciones/");
$imagen->setNombre($cancion->getNombre());
$imagen->setPolitica(FileUpload::RENOMBRAR);
$imagen->upload();
header("Location:index.php");
示例15: FileUpload
function m_uploadImage()
{
$fileUpload = new FileUpload();
if ($this->request['type'] == "menu") {
$this->obDb->query = "SELECT vImage from " . MENUITEMS . " WHERE iMenuItemsId=" . $this->request['id'];
$rsImage = $this->obDb->fetchQuery();
} else {
$this->obDb->query = "SELECT vImage from " . MENUHEADERS . " WHERE iHeaderid_PK=" . $this->request['id'];
$rsImage = $this->obDb->fetchQuery();
}
if ($this->libFunc->checkImageUpload("image")) {
$fileUpload->source = $_FILES["image"]["tmp_name"];
$fileUpload->target = $this->imagePath . "menu/" . $_FILES["image"]["name"];
$newName1 = $fileUpload->upload();
if ($newName1 != false) {
$image = $newName1;
}
if (!empty($rsImage[0]->vImage)) {
$fileUpload->deleteFile($this->imagePath . "menu/" . $rsImage[0]->vImage);
}
$imagename = "image";
} else {
$image = $rsImage[0]->vImage;
}
if ($this->request['type'] == "menu") {
$this->obDb->query = "UPDATE " . MENUITEMS . " SET `vImage`='{$image}' ,`tmEditDate`='" . time() . "', `iAdminUser` ='" . $_SESSION['uid'] . "' WHERE iMenuItemsId ='" . $this->request['id'] . "'";
} else {
$this->obDb->query = "UPDATE " . MENUHEADERS . " SET `vImage`='{$image}',`tmEditDate`='" . time() . "', `iAdminUser` ='" . $_SESSION['uid'] . "' WHERE iHeaderid_PK ='" . $this->request['id'] . "'";
}
$this->obDb->updateQuery();
$this->libFunc->m_mosRedirect(SITE_URL . "ecom/adminindex.php?action=ec_menu.uploadForm&status=1&id=" . $this->request['id'] . "&type=" . $this->request['type']);
}