本文整理汇总了PHP中Upload::do_upload方法的典型用法代码示例。如果您正苦于以下问题:PHP Upload::do_upload方法的具体用法?PHP Upload::do_upload怎么用?PHP Upload::do_upload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Upload
的用法示例。
在下文中一共展示了Upload::do_upload方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_upload
function do_upload()
{
include "classes/Upload.php";
$config['upload_path'] = './uploads/';
// $config['allowed_types'] = '';
$config['max_size'] = '100';
$UpFile = new Upload($config);
if (!$UpFile->do_upload()) {
echo "<span style='color:#ff0000;'>Se ha producido un error</span>";
index();
} else {
$dataFile = $UpFile->data();
$file = 'uploads/' . $dataFile['file_name'];
$pass = $_POST['pass'];
//$output = system('./revtrans.php --password='.$pass.' '.$file);
//printf("System Outputs: $output\n");
exec('./revtrans.php --password=' . $pass . ' ' . $file, $results);
//parser mejorable pero bueno
$results = implode($results);
$results = str_replace('""', '#', $results);
$results = str_replace(',', '#', $results);
$results = str_replace('"', '', $results);
$results = preg_split("/#/", $results);
$i = 0;
$aux = 0;
$Keys = array();
foreach ($results as $result) {
$Keys[$aux][] = $result;
$i++;
if ($i == 5) {
$i = 0;
$aux++;
}
}
//print_r($Keys);
$i = 0;
foreach ($Keys as $Key) {
if ($i != 0) {
echo $Key[0] . "=>" . $Key[2] . "<br>";
}
$i++;
}
}
}
示例2: array
*/
exit;
header('Content-type: application/json');
global $lang;
require_once __DIR__ . '/inc/Image_lib.php';
require_once __DIR__ . '/inc/Upload.php';
require_once __DIR__ . '/inc/upload_lang.php';
$allowedTypes = array('jpg', 'png');
$imagePath = __DIR__ . '/upload/';
$config = array();
$config['upload_path'] = $imagePath;
$config['allowed_types'] = implode('|', $allowedTypes);
$config['max_size'] = '10000';
$upload = new Upload($config);
// $imageLib = new Image_lib();
if (!$upload->do_upload('uploadImage')) {
$error = trim(strip_tags($upload->display_errors()));
$returnObject = array('status' => 'error', 'message' => $lang[$error]);
echo json_encode($returnObject);
} else {
$fileData = $upload->data();
$imageFile = $imagePath . $fileData['file_name'];
$imagePathParts = pathinfo($imageFile);
if (!($imageContent = @file_get_contents($imageFile))) {
$returnObject = array('status' => 'error', 'message' => 'Произошла ошибка на сервере');
echo json_encode($returnObject);
exit;
}
@unlink($imageFile);
$returnObject = array('status' => 'success', 'extension' => $imagePathParts['extension'], 'image' => 'data:' . $fileData['file_type'] . ';base64,' . base64_encode($imageContent));
echo json_encode(array_merge($returnObject));
示例3: elseif
$sent = false;
} elseif (empty($captchaWords)) {
$message = "Символы на изображении не были введены";
$sent = false;
} elseif ($captcha_words != $captchaWords) {
$message = "Цифры на картинке должны совпадать";
$sent = false;
} else {
$path_to_upload = realpath(dirname(__FILE__) . '/../../uploads');
$config = array();
$config['upload_path'] = $path_to_upload;
$config['allowed_types'] = 'gif|jpg|jpeg|png|pdf|html|htm|shtml|txt|text|doc|docx|word|xlsx';
$config['encrypt_name'] = true;
$uploadData = array();
$Upload = new Upload($config);
if (!$Upload->do_upload('resume_file')) {
$error = array('error' => $Upload->display_errors());
} else {
$uploadData = array('upload_data' => $Upload->data('resume_file'));
// [new] input name (type file)
}
if (!empty($firstName) && !empty($lastName)) {
$user = get_user_by('login', 'admin');
$blog_title = get_bloginfo();
$htmlBody = "\n <html>\n <head>\n <title>Резюме</title>\n </head>\n <body>\n <table>\n <tr><td><strong>Имя:</strong></td><td>" . $firstName . "</td></tr>\n <tr><td><strong>Фамилия:</strong></td><td>" . $lastName . "</td></tr>\n <tr><td><strong>Коментарий:</strong></td><td>" . $comment . "</td></tr>\n </table>\n </body>\n </html>";
$config = array();
$Mail = new Mail($config);
$Mail->set_mailtype('html');
if (!empty($uploadData) && (isset($uploadData['upload_data']) && !empty($uploadData['upload_data']))) {
$Mail->attach($uploadData['upload_data']['full_path']);
}
示例4: isset
<?php
require "../include/init/init.php";
$id = isset($_GET["id"]) ? (int) $_GET["id"] : 1;
// 查询数据
$dataselect = $db->where("news_id={$id}")->get("ty_news")->row_array();
var_dump($dataselect);
if ($_POST) {
$name = trim($_POST["name"]) ? $_POST["name"] : "";
$content = trim($_POST["content"]) ? $_POST["content"] : "";
$time = strtotime($_POST["time"]);
$description = trim($_POST["description"]) ? $_POST["description"] : "";
$upload = new Upload('./upload');
if ($_POST["is_file"] == 0) {
if ($upload->do_upload('thumb')) {
$thumbdata = $upload->data();
$data = array("news_name" => "{$name}", "news_content" => "{$content}", "news_time" => "{$time}", "news_description" => "{$description}", "news_small_thumb" => "{$thumbdata['full_path']}");
$db->where("news_id={$id}")->update("ty_news", $data, "./news.php");
}
} else {
$data = array("news_name" => "{$name}", "news_content" => "{$content}", "news_time" => "{$time}", "news_description" => "{$description}");
$db->where("news_id={$id}")->update("ty_news", $data, "./news.php");
}
}
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
示例5: header
<?php
include 'include/function.php';
include 'include/config.php';
include 'include/uploader.php';
include 'include/db.php';
include 'include/pagination.php';
error_reporting(E_ALL);
if (!is_logged()) {
header("location: {$config['base_url']}");
exit;
}
$db = new DB();
if (isset($_POST['submit'])) {
$up = new Upload();
if ($up->do_upload()) {
$data = $up->data();
$sess_id = intval($_SESSION['id']);
$i_title = $db->escape_string($_POST['title']);
$i_artist = $db->escape_string($_POST['artist']);
$path = $db->escape_string($data['file_path']);
$sql = "INSERT INTO songs (`title`, `artist`, `path`, `owner`) VALUES ('{$i_title}','{$i_artist}','{$path}',{$sess_id});";
if (!$db->query($sql)) {
die($db->error);
}
} elseif (isset($_POST['url']) and !empty($_POST['url'])) {
$sess_id = intval($_SESSION['id']);
$i_title = $db->escape_string($_POST['title']);
$i_artist = $db->escape_string($_POST['artist']);
$sql = "INSERT INTO songs (`title`, `artist`, `path`, `owner`) VALUES ('{$i_title}','{$i_artist}','{$db->escape_string($_POST['url'])}',{$sess_id});";
if (!$db->query($sql)) {