-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathprocess.php
53 lines (39 loc) · 1.61 KB
/
process.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
############ Configuration ##############
$config["generate_image_file"] = true;
$config["generate_thumbnails"] = true;
$config["image_max_size"] = 500; //Maximum image size (height and width)
$config["thumbnail_size"] = 200; //Thumbnails will be cropped to 200x200 pixels
$config["thumbnail_prefix"] = "thumb_"; //Normal thumb Prefix
$config["destination_folder"] = 'home/Website/ajax-image-upload/uploads/'; //upload directory ends with / (slash)
$config["thumbnail_destination_folder"] = 'home/Website/ajax-image-upload/uploads/'; //upload directory ends with / (slash)
$config["upload_url"] = "http://website/ajax-image-upload/uploads/";
$config["quality"] = 90; //jpeg quality
$config["random_file_name"] = true; //randomize each file name
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
exit; //try detect AJAX request, simply exist if no Ajax
}
//specify uploaded file variable
$config["file_data"] = $_FILES["__files"];
//include sanwebe impage resize class
include("resize.class.php");
//create class instance
$im = new ImageResize($config);
try{
$responses = $im->resize(); //initiate image resize
echo '<h3>Thumbnails</h3>';
//output thumbnails
foreach($responses["thumbs"] as $response){
echo '<img src="'.$config["upload_url"].$response.'" class="thumbnails" title="'.$response.'" />';
}
echo '<h3>Images</h3>';
//output images
foreach($responses["images"] as $response){
echo '<img src="'.$config["upload_url"].$response.'" class="images" title="'.$response.'" />';
}
}catch(Exception $e){
echo '<div class="error">';
echo $e->getMessage();
echo '</div>';
}
?>