Esempio n. 1
0
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);
}
Esempio n. 2
0
                $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&amp;mod=show_cat&amp;do=' . $do . '">Proceed</a></div>';
                    } else {
                        echo functions::display_error($handle->error());
                        echo '<div class="menu"><a href="?act=smileys&amp;mod=upload&amp;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;
Esempio n. 3
0
 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;
 }