本文整理匯總了PHP中upload::error方法的典型用法代碼示例。如果您正苦於以下問題:PHP upload::error方法的具體用法?PHP upload::error怎麽用?PHP upload::error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類upload
的用法示例。
在下文中一共展示了upload::error方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: upload
function upload($image)
{
include "upload.inc.php";
// Defining Class
$yukle = new upload();
// Set Max Size
$yukle->set_max_size(180000);
// Set Directory
$yukle->set_directory("/home/jimgreen/public_html/images/" . $image . "");
// Do not change
// Set Temp Name for upload, $_FILES['file']['tmp_name'] is automaticly get the temp name
$yukle->set_tmp_name($_FILES['file']['tmp_name']);
// Do not change
// Set file size, $_FILES['file']['size'] is automaticly get the size
$yukle->set_file_size($_FILES['file']['size']);
// Do not change
// Set File Type, $_FILES['file']['type'] is automaticly get the type
$yukle->set_file_type($_FILES['file']['type']);
// Set File Name, $_FILES['file']['name'] is automaticly get the file name.. you can change
$yukle->set_file_name($_FILES['file']['name']);
// Start Copy Process
$yukle->start_copy();
// If uploaded file is image, you can resize the image width and height
// Support gif, jpg, png
$yukle->resize(218, 218);
// Control File is uploaded or not
// If there is error write the error message
if ($yukle->is_ok()) {
echo "ok";
} else {
echo $yukle->error() . "<br>";
}
// Set a thumbnail name
$yukle->set_thumbnail_name("thumb1");
// create thumbnail
$yukle->create_thumbnail();
// change thumbnail size
$yukle->set_thumbnail_size(0, 250);
$yukle->set_thumbnail_name("thumb2");
$yukle->create_thumbnail();
$yukle->set_thumbnail_size(50, 0);
$yukle->set_thumbnail_name("thumb3");
$yukle->create_thumbnail();
$yukle->set_thumbnail_size(62, 150);
}
示例2: upload
$handle = new upload($_FILES['smiley']);
if ($handle->uploaded) {
// Обрабатываем фото
$handle->file_new_name_body = $name;
$handle->allowed = array('image/jpeg', 'image/gif', 'image/png');
$handle->file_max_size = 1024 * $set['flsz'];
$handle->file_overwrite = true;
$handle->image_ratio_no_zoom_in = true;
$handle->image_x = 100;
$handle->image_y = 100;
$handle->process($c);
if ($handle->processed) {
echo '<div class="gmenu">Smile has been successfully uploaded!</div>';
echo '<div class="menu"><a href="?act=smileys&mod=show_cat&do=' . $do . '">Proceed</a></div>';
} else {
echo functions::display_error($handle->error());
echo '<div class="menu"><a href="?act=smileys&mod=upload&do=' . $do . '">' . $lng['repeat'] . '</a></div>';
}
$handle->clean();
}
require_once '../incfiles/end.php';
exit;
}
}
echo '<form method="POST" enctype="multipart/form-data"><div class="gmenu">';
echo 'Allowed file (' . implode(', ', $ext) . '):<br />
<input type="file" name="smiley"/>';
echo '<br />Name:<br /><input name="name" /><br />
<input type="submit" name="submit" value="Upload"/>';
echo '</div></form></div>';
break;
示例3: set_error
private static function set_error()
{
/*
0——沒有錯誤發生,文件上傳成功。
1——上傳的文件超過了 php.ini 中 upload_max_filesize 選項限製的值。
2——上傳文件的大小超過了 HTML 表單中 MAX_FILE_SIZE 選項指定的值。
3——文件隻有部分被上傳。
4——沒有文件被上傳。
*/
if (self::$files['size'] > self::$filesize) {
self::$error = "文件大小超過了允許上傳大小";
return false;
}
switch (self::$files['error']) {
case 0:
self::$error = "上傳成功沒有錯誤";
return true;
break;
case 1:
self::$error = "文件大小超過了ini大小";
return false;
break;
case 2:
self::$error = "文件大小超過了HTML大小";
return false;
break;
case 3:
self::$error = "文件隻有部分被上傳";
return false;
break;
case 4:
self::$error = "文件沒有被上傳";
return false;
break;
default:
return false;
break;
}
return true;
}