Beispiel #1
0
 if ($slideshow_total > $ini_max_upload * 1024000) {
     $type = 'danger';
     $msg = 'Error: Total files upload more than server configuration allowed (Total your file(s) size: ' . $slideshow_total / 1024 . 'kB).';
     set_alert($type, $msg);
     safe_redirect('home');
     /* --- FILE TYPE (IMAGE: JPG, PNG, GIF ONLY) --- */
 } else {
     if (!in_array($file_type, $allowed_type)) {
         $type = 'danger';
         $msg = 'Error: Image format not allowed (allowed image format: .jpg, .png, .gif).';
         set_alert($type, $msg);
         safe_redirect('home');
     } else {
         if (move_uploaded_file($userfile_tmp, $prod_img) && $file_error == 0) {
         } else {
             $temptation = upload_code_message($file_error);
             $type = 'danger';
             $msg = 'Error: ' . $temptation;
             set_alert($type, $msg);
             safe_redirect('home');
         }
     }
 }
 $slider_image = $prefix . $userfile_name;
 $filename = 'files/uploads/slideshow/' . $prefix . $userfile_name;
 if ($validate->rows > 0) {
     unlink("../" . $get_slideshow->filename);
     $_update->update_slideshow($filename, $id);
 } else {
     $_update->insert_slideshow($id, $filename, $id);
 }
Beispiel #2
0
     } else {
         if (!in_array($file_type, $allowed_type)) {
             $type = 'danger';
             $msg = 'Error: Image format not allowed (allowed image format: .jpg, .png, .gif).';
             set_alert($type, $msg);
             safe_redirect('add-news');
         } else {
             if (move_uploaded_file($userfile_tmp, $prod_img) && $file_error == 0) {
             } else {
                 if (!move_uploaded_file($userfile_tmp, $prod_img)) {
                     $type = 'danger';
                     $msg = 'Error: Permission denied, check folder: ' . $uploads_dir . ' permission';
                     set_alert($type, $msg);
                     safe_redirect('add-news');
                 } else {
                     $error_msg = upload_code_message($file_error);
                     $type = 'danger';
                     $msg = 'Error: ' . $error_msg;
                     set_alert($type, $msg);
                     safe_redirect('add-news');
                 }
             }
         }
     }
     $image = substr($prod_img, 2);
 } else {
     $image = '';
 }
 $address = filter_var($_POST['address'], FILTER_SANITIZE_STRING);
 if ($_update->insertNews($category, $title, $alias, $date, $address, $excerpt, $content, $created_date, $description, $keywords, $visibility, $order->order + 1)) {
 } else {
Beispiel #3
0
function upload_image($files, $upload_dir, $prefix, $page)
{
    /* --- FILE: NAME & TYPE --- */
    $files_name = substr($files['name'], 0, -4);
    $file_type = substr($files['name'], -4);
    $uploads_dir = $upload_dir;
    $name = cleanurl(str_replace(array('(', ')', ' '), '_', $files_name)) . $file_type;
    $tmp = $files['tmp_name'];
    $prefix = $prefix;
    $prod_img = $uploads_dir . $prefix . $name;
    $error = $files['error'];
    if ($error == 0) {
        if (move_uploaded_file($tmp, $prod_img)) {
            $filename = $prod_img;
        } else {
            $type = 'danger';
            $msg = "Image upload failed";
            set_alert($type, $msg);
            safe_redirect($page);
        }
    } else {
        $type = 'danger';
        $msg = 'Error: ' . upload_code_message($error);
        set_alert($type, $msg);
        safe_redirect($page);
    }
    return $filename;
}