Ejemplo n.º 1
0
        $new_image = imagecreatetruecolor($newWidth, $newHeight);
        imagecopyresized($new_image, $old_image, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
        $imgt($new_image, $updir . "" . $id . "_t.jpg");
        return;
    }
}
// ###################### START MAIN UPLOAD SCRIPT #######################
if (!empty($_FILES)) {
    if ($file_transfer_on == 1 || $chatroom_transfer_on == 1) {
        $tempFile = $_FILES['Filedata']['tmp_name'];
        $targetPath = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . AC_FOLDER_UPLOADS . DIRECTORY_SEPARATOR;
        $fileParts = pathinfo($_FILES['Filedata']['name']);
        $targetFile = $targetPath . $db->escape_string($_POST['unixtime']) . "." . $fileParts['extension'];
        $ext = strtolower($fileParts['extension']);
        // Exit if the image is not a valid image
        if (!exif_imagetype($tempFile) && ($ext == "jpg" || $ext == "gif" || $ext == "png" || $ext == "jpeg")) {
            http_response_code(500);
            exit;
        }
        // Make a thumbnail if it is an image
        if ($ext == "jpg" || $ext == "gif" || $ext == "png" || $ext == "jpeg") {
            makeThumbnails($targetPath, $tempFile, $db->escape_string($_POST['unixtime']));
        }
        // Move the file to the uploads directory
        move_uploaded_file($tempFile, $targetFile);
        echo str_replace(dirname(dirname(dirname(dirname(__FILE__)))), '', $targetFile);
    } else {
        http_response_code(500);
        exit;
    }
}
             //thumbnails
             $msg = "Album created successfully";
             header("Location: ../index.php?s=true&t=CrALB");
         } else {
             header("Location: ../index.php?s=false&t=CrALB");
         }
     }
     break;
 case "upload_photo":
     $albumID = $_POST["album_id"];
     $albumName = $_POST["album_name"];
     $imgTmp = $_FILES["imgFile"]["tmp_name"];
     $imgName = $_FILES["imgFile"]["name"];
     if (move_uploaded_file($imgTmp, $uploadsDir . "/" . $albumName . "/" . $imgName)) {
         makeThumbnails($uploadsDir . "/" . $albumName, $imgName);
         makeThumbnails($uploadsDir . "/" . $albumName, $imgName, "", 1024, 768);
         //Big image
         $qry = "INSERT INTO tbl_photos (AID, file_name) VALUES(" . $albumID . ", '" . $imgName . "')";
         mysql_query($qry);
         echo 'success';
     }
     break;
 case "setCover":
     $imgID = $_REQUEST["imgID"];
     $albID = $_REQUEST["albID"];
     $albName = $_REQUEST["albName"];
     $qry = "UPDATE tbl_gallery SET CID=" . $imgID . " WHERE AID=" . $albID;
     $qryImg = "UPDATE tbl_photos SET cover_status=1 WHERE PID=" . $imgID;
     if (mysql_query($qry)) {
         mysql_query("UPDATE tbl_photos SET cover_status=0");
         mysql_query($qryImg);
Ejemplo n.º 3
0
function check_thumb_name($name, $name1, $path, $width, $height, $table, $col_name, $dest)
{
    // Check if the file name exist already
    global $db, $flag;
    $query = $db->query("SELECT {$col_name} FROM {$table} WHERE {$col_name} = '{$name}'");
    $query = $query->fetchAll();
    if (empty($query)) {
        makeThumbnails($name, $name1, $path, $width, $height, $col_name, $table, $dest);
    } else {
        $todays_date = date("mdYHis");
        // $name = str_replace(',', '' , $name);
        $new_filename = $todays_date . '_' . $name1;
        // rename($name, $new_filename);
        makeThumbnails($name, $new_filename, $path, $width, $height, $col_name, $table, $dest);
    }
}
Ejemplo n.º 4
0
        $ext = explode('.', basename($_FILES['file']['name'][$i]));
        //explode file name from dot(.)
        $file_extension = end($ext);
        //store extensions in the variable
        $target_path = $target_path . md5(uniqid()) . "." . $ext[count($ext) - 1];
        //set the target path with a new name of image
        $j = $j + 1;
        //increment the number of uploaded images according to the files in array
        if ($_FILES["file"]["size"][$i] < $max_file_size && in_array($file_extension, $validextensions)) {
            if (move_uploaded_file($_FILES['file']['tmp_name'][$i], $target_path)) {
                //if file moved to uploads folder
                $x = $i + 1;
                $title = $_POST['txt' . $j];
                $desc = $_POST['dsc' . $j];
                $stmt = $conn->prepare("INSERT INTO aperture (filename,title,description,dateuploaded) VALUES (?, ?, ?,NOW())");
                $stmt->bind_param("sss", $target_path, $title, $desc);
                $stmt->execute();
                $stmt->close();
                makeThumbnails($target_path);
                echo $j . ').<span id="noerror">Image uploaded successfully!.</span><br/><br/>';
            } else {
                //if file was not moved.
                echo $j . ').<span id="error">please try again!.</span><br/><br/>';
            }
        } else {
            //if file size and file type was incorrect.
            echo $j . ').<span id="error">***Invalid file Size or Type***</span><br/><br/>';
        }
    }
    $conn->close();
}