|
1 | | -# Multi Files Uploader PHP |
| 1 | +# resize-and-upload-multiple-images-using-php-and-ajax |
2 | 2 |
|
3 | | -1) Resize Images |
4 | | -2) Change quality of images |
5 | | -3) Add watermark |
6 | | -4) Set watermark position x-y |
7 | | -5) Check uploading imaegs size |
8 | | -6) Rename images |
| 3 | +View online complete documentation and integration <a href="https://learncodeweb.com/web-development/resize-and-upload-multiple-images-using-php-and-ajax/">Click Here</a> |
9 | 4 |
|
10 | | ----------------- |
11 | | -This is very basic class that you can use for upload images. |
12 | | - |
13 | | -By using this class you can change the ***QUALITY*** of the image, Add water mark and you also can ***RESIZE*** the image. |
14 | | - |
15 | | -You just need to set the name of your files in a **Dropzone** *like* |
16 | | - |
17 | | -**paramName: "files",** // The name that will be used to transfer the file |
18 | | - |
19 | | -for dropzone read [https://github.com/enyo/dropzone] |
20 | | - |
21 | | -in your PHP file |
22 | | - |
23 | | -```php |
24 | | -require('../az.multi.upload.class.php'); |
25 | | -$rename = rand().time(); // You can choose your own name. |
26 | | -$upload = new ImageUploadAndResize(); // Object create |
27 | | -$upload->uploadFiles('files', '../uploads', 400, '../mini-logo.png', 20, 20, $rename, 0777, 100, ''); |
28 | | -``` |
29 | | -After upload images method will return images Name array that you can use to submit into **DB TABLE** like. |
30 | | - |
31 | | -``` |
32 | | -$db = new mysqli('localhost','root','','test'); |
33 | | -
|
34 | | -print"<pre>"; |
35 | | -foreach($upload->prepareNames as $name){ |
36 | | - $sql = "INSERT INTO YOURTABLE_NAME (YOUR_COL_NAME) VALUES ('".$name."')"; |
37 | | - |
38 | | - if ($db->query($sql) === TRUE) { |
39 | | - echo "New record created successfully"; |
40 | | - } else { |
41 | | - echo "Error: " . $sql . "<br>" . $db->error; |
42 | | - } |
43 | | -} |
44 | | -print"</pre>"; |
45 | | -``` |
46 | | - |
47 | | -All parameters that you need to set |
48 | | - |
49 | | -```php |
50 | | -$yourFileName = 'Your paramName' // Set in a Dropzone |
51 | | -$yourDestination = '../upload' // Folder/Dir name where you need to save images |
52 | | -$minImgWidth = 400 //Set to check Minimum width of uploaded images. |
53 | | -$waterMarkImgSrc = '../mini-logo.png' //Set watermark |
54 | | -$xPosition = 20 //Set position of watermark X-AXIS |
55 | | -$yPosition = 20 //Set position of watermark Y-AXIS |
56 | | -$reName = 'Rename uploaded file if you need' // Left empty save file default name |
57 | | -$permission = 0655 // Folder/Dir permission set 0777 for full access |
58 | | -$quality = 100 // Set image quality you can set it between 1-100 |
59 | | -$newWidth = '' // If you want to resize the image then pass int value else upload without resizing |
60 | | -``` |
| 5 | +View working example <a href="https://learncodeweb.com/web-development/resize-and-upload-multiple-images-using-php-and-ajax/">View Demo</a> |
61 | 6 |
|
62 | 7 | Thank you |
63 | 8 |
|
|
0 commit comments