本文整理汇总了PHP中upload函数的典型用法代码示例。如果您正苦于以下问题:PHP upload函数的具体用法?PHP upload怎么用?PHP upload使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了upload函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upload
/**
* Author : Jan Germann
* Datum : 26.04.2010
* Modul : files
* Beschreibung : Dateien Hochladen in UPLOAD_DIR
*/
function upload()
{
global $msg, $mysql, $log;
if (!isset($_POST['submit'])) {
$tpl = dirname(__FILE__) . "/template/upload.form.tpl";
if (is_file($tpl)) {
$template = file_get_contents($tpl);
}
$template = str_replace("%name%", $_POST['name'], $template);
$template = str_replace("%description%", $_POST['description'], $template);
return $data = $template;
} else {
if ($_FILES['file']['error'] == 4) {
$msg->error("Es wurde keine Datei hochgeladen.");
}
if (empty($_POST['name'])) {
$msg->error("Es wurde kein Name angegeben.");
}
if ($msg->error) {
unset($_POST['submit']);
return upload();
} else {
$safe_filename = preg_replace(array("/\\s+/", "/[^-\\.\\w]+/"), array("_", ""), trim($_FILES['file']['name']));
if (is_uploaded_file($_FILES['file']['tmp_name']) && !@move_uploaded_file($_FILES['file']['tmp_name'], UPLOAD_DIR . $safe_filename)) {
$msg->error("Fehler beim Dateiupload.");
unset($_POST['submit']);
return upload();
}
$mysql->insert("files", array(NULL, mysql_real_escape_string($_POST['name']), mysql_real_escape_string($_POST['description']), $safe_filename));
$msg->success("Upload erfolgreich.");
$log->add("Dateiupload", "<file>" . $safe_filename . "</file><name>" . mysql_real_escape_string($_POST['name']) . "</name><description>" . mysql_real_escape_string($_POST['description']) . "</description>");
}
}
}
示例2: lisa
function lisa()
{
// siia on vaja funktsionaalsust (13. nädalal)
if (!empty($_SESSION["user"])) {
if ($_SERVER['REQUEST_METHOD'] == "POST") {
// postitus on tehtud
if (in_array("", $_POST) || $_FILES["pilt"]["error"] > 0) {
$errors[] = "Mingi väli jäi postitamisel tühjaks või on faili üleslaadimisel tekkinud viga.";
include_once 'views/loomavorm.html';
} else {
// kõik ok, laeme faili üles ja teeme kirje tabelisse
connect_db();
upload("pilt");
$query = "INSERT INTO ttilk__loomaaed (NIMI, PUUR, PILT) \n\t\t\t\t\t\t\tVALUES ('" . mysqli_real_escape_string($GLOBALS['connection'], $_POST["nimi"]) . "', '" . mysqli_real_escape_string($GLOBALS['connection'], $_POST["puur"]) . "', '" . "pildid/" . $_FILES["pilt"]["name"] . "');";
$result = mysqli_query($GLOBALS['connection'], $query) or die("{$query} - " . mysqli_error($GLOBALS['connection']));
echo $_FILES["pilt"]["name"];
//header("refresh:3; url=loomaaed.php?page=loomad");
}
// if
} else {
include_once 'views/loomavorm.html';
}
// if $_SERVER
} else {
header("Location: loomaaed.php?page=login");
}
// if !empty
}
示例3: pic
public function pic()
{
if (isset($_FILES['headpic']['name']) && strlen($_FILES['headpic']['name']) > 0) {
$arr = array('upload' => 'headpic', 'ext' => array('jpg', 'jpeg', 'png', 'gif'), 'size' => 10240, 'path' => './asset/upload/');
$file = upload($arr);
if ($file['result']) {
$user = new UserModel();
$picName = $file['message'];
$rst = $user->setPics($picName);
if ($rst) {
R('User', 'ePic');
//$newUrl = U('User','ePic');
//echo "<script>window.location='http://localhost/YYK/msg/User/ePic.html'</script>";
} else {
//E($this->errors['054']);
var_dump($rst);
echo "Wrong!~";
}
} else {
//E($file['message']);
echo "Wrong";
}
} else {
var_dump($_FILES);
}
}
示例4: lisa
function lisa()
{
global $connection;
if (empty($_SESSION["user"])) {
header("Location: ?page=login");
} else {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($_POST["nimi"] == '' || $_POST["puur"] == '') {
$errors = array();
if (empty($_POST["nimi"])) {
$errors[] = "Palun sisesta nimi!";
}
if (empty($_POST["puur"])) {
$errors[] = "Palun sisesta puur!";
}
} else {
upload('liik');
$nimi = mysqli_real_escape_string($connection, $_POST["nimi"]);
$puur = mysqli_real_escape_string($connection, $_POST["puur"]);
$liik = mysqli_real_escape_string($connection, "pildid/" . $_FILES["liik"]["name"]);
$sql = "INSERT INTO kleemets_loomaaed (nimi, PUUR, liik) VALUES ('{$nimi}','{$puur}','{$liik}')";
$result = mysqli_query($connection, $sql);
$id = mysqli_insert_id($connection);
if ($id) {
header("Location: ?page=loomad");
} else {
header("Location: ?page=loomavorm");
}
}
}
}
include_once 'views/loomavorm.html';
}
示例5: uploadFile
function uploadFile()
{
global $_POST;
global $_FILES;
global $ATTACHMENT_ID_OLD;
global $ATTACHMENT_NAME_OLD;
if ($_POST['通达格式上传文件'] != "") {
if (count($_FILES) > 1) {
$ATTACHMENTS = upload();
$CONTENT = ReplaceImageSrc($CONTENT, $ATTACHMENTS);
$ATTACHMENT_ID = $ATTACHMENT_ID_OLD . $ATTACHMENTS["ID"];
$ATTACHMENT_NAME = $ATTACHMENT_NAME_OLD . $ATTACHMENTS["NAME"];
} else {
$ATTACHMENT_ID = $ATTACHMENT_ID_OLD;
$ATTACHMENT_NAME = $ATTACHMENT_NAME_OLD;
}
$ATTACHMENT_ID .= copy_sel_attach($ATTACH_NAME, $ATTACH_DIR, $DISK_ID);
$ATTACHMENT_NAME .= $ATTACH_NAME;
$上传附件字段名称 = $_POST['通达格式上传文件'];
//对附件上传字段重新赋值
$_POST[$上传附件字段名称] = $ATTACHMENT_NAME . "||" . $ATTACHMENT_ID;
//print_R($_POST);print_R($_FILES);print_R($ATTACHMENT_NAME);print_R($ATTACHMENT_ID);exit;
}
//通达格式上传文件处理结束
}
示例6: saveKimport
function saveKimport($option)
{
if (isset($_FILES['uploadfile']) && is_array($_FILES['uploadfile'])) {
$file = $_FILES['uploadfile'];
upload($option, $file, '');
}
}
示例7: lisa
function lisa()
{
// siia on vaja funktsionaalsust (13. nädalal)
$errors = array();
if (!empty($_SESSION['username'])) {
include_once 'views/login.html';
} else {
if ($_SERVER['REQUEST_METHOD'] == "POST") {
if (in_array("", $_POST)) {
$errors[] = "Väljad täita!";
include_once 'views/loomavorm.html';
} else {
global $connection;
upload('liik');
$nimi = mysqli_real_escape_string($connection, $_POST['nimi']);
$puur = mysqli_real_escape_string($connection, $_POST['puur']);
$liik = mysqli_real_escape_string($connection, "pildid/" . $_FILES["liik"]["name"]);
$query = "INSERT INTO aveinber_loomaaed (nimi, puur, liik ) values ('{$nimi}','{$puur}','{$liik}')";
$result = mysqli_query($connection, $query) or die("Ei saanud päringut teha " . mysqli_error($connection));
header('Location:loomaaed.php?page=loomad');
}
} else {
include_once 'views/loomavorm.html';
}
}
}
示例8: internal_upload
/**
* Functions registered with the worker
*
* @param object $job
* @return void
*/
function internal_upload($job)
{
//Get the info of the job
list($localFilename, $remoteFilename, $removeFile) = unserialize($job->workload());
//Default value if empty
if (is_null($removeFile)) {
$removeFile = FALSE;
}
//Do some checks
if (empty($localFilename) || empty($remoteFilename)) {
logError(sprintf("%s: The workload do not contain the required info to do the upload\n\n", date('r')));
$job->sendFail();
return FALSE;
}
echo sprintf("%s: Received job to internal upload %s\n", date('r'), $localFilename);
//Do the upload
$uploaded = upload($localFilename, $remoteFilename);
if ($uploaded !== TRUE) {
logError(sprintf("%s: Error while uploading the file to Amazon S3 - %s\n\n", date('r'), $uploaded->getMessage()));
$job->sendFail();
return FALSE;
}
//Check if we have to remove the file
if ($removeFile) {
//Remove the original file
if (!unlink(ROOT_PATH . '/public/frontend/tmp/' . $localFilename)) {
logError(sprintf("%s: Error removing the file\n\n", date('r')));
$job->sendFail();
return FALSE;
}
}
$job->sendComplete(TRUE);
echo sprintf("%s: Job finished successfully\n\n", date('r'));
return TRUE;
}
示例9: lisa
function lisa()
{
// siia on vaja funktsionaalsust (13. nädalal)
global $connection;
if (isset($_SESSION['user_role']) && $_SESSION['user_role'] == "admin") {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$upload_field_name = 'liik';
if (empty($_POST['nimi'])) {
$errors['empty_name'] = "Sisesta nimi";
}
if (empty($_POST['puur'])) {
$errors['empty_cage'] = "Sisesta puur";
}
//if(empty($_POST['liik'])) $errors['empty_species'] = "Sisesta liik";
if (upload($upload_field_name) == "") {
$errors['upload_failed'] = "Faili upload ebaõnnestus";
}
$speciesFromImageName = explode(".", $_FILES[$upload_field_name]["name"]);
$insertName = mysqli_real_escape_string($connection, htmlspecialchars($_POST['nimi']));
$insertCage = mysqli_real_escape_string($connection, htmlspecialchars($_POST['puur']));
$insertSpecies = mysqli_real_escape_string($connection, htmlspecialchars($speciesFromImageName[0]));
$sql = "INSERT INTO `rturi_zoo`(`name`, `species`, `cage`) VALUES ('" . $insertName . "','" . $insertSpecies . "'," . $insertCage . ")";
$result = mysqli_query($connection, $sql) or die("{$sql} - " . mysqli_error($connection));
echo mysqli_insert_id($connection);
if (mysqli_insert_id($connection) > 0) {
header("Location: ?page=loomad");
exit(0);
}
}
} else {
header("Location: ?");
exit(0);
}
include_once 'views/loomavorm.html';
}
示例10: uploadResume
public function uploadResume($file, $pdfPath, $thumbPath)
{
$types = array("application/pdf", "application/x-pdf", "text/pdf", "application/acrobat", "application/vnd.pdf", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
$pad = str_replace(" ", "_", $this->fullName);
$attempt = upload($pdfPath, $file, $pad, $types);
if (!is_array($attempt)) {
return $attempt;
}
if (!array_key_exists("main_name", $attempt) || !array_key_exists("new_name", $attempt)) {
return $attempt;
}
$newName = $attempt['new_name'];
$conn = new PDO(DB_DSN, DB_USER, DB_PASS);
$sql = "INSERT INTO seekers(userID, cv_file) VALUES(:id, :file)";
if ($this->getResumeFile()) {
$sql = "UPDATE seekers SET cv_file = :file WHERE userID = :id";
}
$st = $conn->prepare($sql);
$st->bindParam(":id", $this->userID);
$st->bindParam(":file", $newName);
try {
if (!$st->execute()) {
unlink($pdfPath . $newName);
return $st->errorInfo();
} else {
$mainFile = $pdfPath . $newName;
$thumb = $newName . ".jpg";
//execute ImageMagick's convert command
//exec("covert \"{$mainFile[0]}\" -colorspace RGB -geometry 400 $thumbPath$thumb");
return true;
}
} catch (PDOException $e) {
return $e->getMessage();
}
}
示例11: upload
public function upload()
{
$data = upload('./Wx/Material/');
if (is_array($data)) {
$path = 'http://' . $_SERVER['HTTP_HOST'] . ltrim($data['file']['file_save_path'], '.');
$this->ajaxSuccess($path);
}
$this->ajaxError('上传失败' . $data);
}
示例12: doUpload
function doUpload()
{
// Metadaten zu Banner angegeben?
if (empty($_GET["tag"]) || empty($_GET["name"])) {
die(json_encode(array("error" => "FORM VALIDATION: Kein Allianzname oder kein Allianztag angegeben.")));
}
// Datei hochgeladen?
if (empty($_FILES[UPLOAD_BANNER_ID])) {
die(json_encode(array("error" => "FORM VALIDATION: Keine Datei zum Hochladen ausgew&aauml;hlt.")));
}
// Fehler beim upload
if (isset($_FILES[UPLOAD_BANNER_ID]['error']) && intval($_FILES[UPLOAD_BANNER_ID]['error']) > 0) {
switch ($_FILES[UPLOAD_BANNER_ID]['error']) {
case '1':
$error = 'The uploaded file exceeds the upload_max_filesize directive in php.ini';
break;
case '2':
$error = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form';
break;
case '3':
$error = 'The uploaded file was only partially uploaded';
break;
case '4':
$error = 'No file was uploaded.';
break;
case '6':
$error = 'Missing a temporary folder';
break;
case '7':
$error = 'Failed to write file to disk';
break;
case '8':
$error = 'File upload stopped by extension';
break;
case '999':
default:
$error = 'No error code avaiable';
}
die(json_encode(array("error" => "UPLOAD ERROR: " . $error . ".")));
}
$tmp_filename = $_FILES[UPLOAD_BANNER_ID]['tmp_name'];
$img_size = getimagesize($tmp_filename);
// Datei ist Bild?
if (!is_array($img_size)) {
die(json_encode(array("error" => "UPLOAD ERROR: Die hochgeladene Datei ist kein Bild.")));
}
// Datei hat richtige Größe?
if ($img_size[0] != BANNER_WIDTH || $img_size[1] != BANNER_HEIGHT) {
die(json_encode(array("error" => "UPLOAD ERROR: Die hochgeladene Datei hat nicht die richtige Größe. (Breite: " + BANNER_WIDTH + ", Höhe: " + BANNER_HEIGHT + ")")));
}
// Allright, copy file and return info
$id = upload($_FILES[UPLOAD_BANNER_ID], $_GET["tag"], $_GET["name"]);
$banner = get_banner($id);
echo '{"success": true, id: "' . $id . '", "filename": "' . rawurlencode($banner["url"]) . '", "path": "' . rawurlencode(BANNER_PATH . $banner["url"]) . '"}';
}
示例13: uploadImg
/**
* 上传图片
*/
public function uploadImg()
{
//'ybFlQ9kmPTgiCWZT8Mq_1YnKtBziwpbaVDaftpJckPtFzlwROlgXpKCd9Dbl_JRs'
if (!empty($_FILES)) {
$info = reset(upload());
$data = Media::upload(realpath($info['file_save_path']), 'image');
file_put_contents('./wx-test/uploadimg.txt', json_encode($data));
dump($data);
}
// dump( Media::upload(realpath('./Public/Uploads/2015-09-23/560218d10525f.jpg'),'image' ));
}
示例14: addAttachment
public function addAttachment($file, $path)
{
$allowed = array("image/jpeg", "image/jpg", "image/png", "image/gif", "application/pdf", "application/x-pdf", "text/pdf", "application/acrobat", "application/vnd.pdf", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
$pad = uniqid('msg_file_', true);
$attempt = upload($path, $file, $pad, $allowed);
if (!is_array($attempt)) {
return $attempt;
}
if (!array_key_exists("main_name", $attempt) || !array_key_exists("new_name", $attempt)) {
return $attempt;
}
}
示例15: processRequest
public function processRequest()
{
if ($_SERVER["REQUEST_METHOD"] == "GET") {
print "WebORB v3.5.0";
}
$timeStart = microtime(true);
ob_start();
$inputData = file_get_contents("php://input");
if (isset($_FILES['Filedata'])) {
$config = ORBConfig::getInstance();
if (!defined("WebOrbServicesPath")) {
define("WebOrbServicesPath", realpath(WebOrb . $config->getServicePath()) . DIRECTORY_SEPARATOR);
if (LOGGING) {
Log::log(LoggingConstants::DEBUG, "WebORB services path is - " . WebOrbServicesPath);
}
}
require_once WebOrbServicesPath . "Weborb/Examples/Upload.php";
upload();
exit;
}
$startRead = microtime(true);
try {
$config = ORBConfig::getInstance();
if (!defined("WebOrbServicesPath")) {
define("WebOrbServicesPath", realpath(WebOrb . $config->getServicePath()) . DIRECTORY_SEPARATOR);
if (LOGGING) {
Log::log(LoggingConstants::DEBUG, "WebORB services path is - " . WebOrbServicesPath);
}
}
$contentType = "text/html";
if (stripos($_SERVER["CONTENT_TYPE"], "wolf/xml") !== false) {
$contentType = "wolf/xml";
} elseif (stripos($_SERVER["CONTENT_TYPE"], "application/x-amf") !== false) {
$contentType = "application/x-amf";
}
$request = $config->getProtocolRegistry()->buildMessage($contentType, $inputData);
} catch (Exception $e) {
if (LOGGING) {
Log::logException(LoggingConstants::ERROR, "Internal error", $e);
}
ob_clean();
return;
}
if (DrupalDispatcher::dispatch($request)) {
$this->serializeResponse($request);
}
$logMessage = sprintf("Final Execute time: %0.3f", microtime(true) - $timeStart);
if (LOGGING) {
Log::log(LoggingConstants::PERFORMANCE, $logMessage);
}
}