本文整理汇总了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;
}