├── README.md ├── php-ajax-jquery-multiple-files-upload ├── index.html ├── php-multiple-files-upload.php └── readme.rst ├── php-ajax-jquery-multiple-rows-delete ├── assets │ ├── css │ │ └── table.css │ └── js │ │ └── app.js ├── db.php ├── delete.php ├── index.php ├── product.sql └── readme.rst ├── php-ajax-jquery-mysql-crud ├── ajax_crud.html ├── create.php ├── db.php ├── delete.php ├── read.php ├── readme.rst └── update.php ├── php-ajax-mysql-username-availability-check ├── auth.php ├── db.php ├── process.php ├── readme.rst └── user.sql ├── php-ajax-single-file-upload ├── ajax_file_upload.php ├── readme.rst └── upload.php ├── php-backup-mysql-database ├── common.php ├── config.php ├── db-backup-1606223329-81497e51521b2b2f70ef29257d165ba0.sql ├── php-backup-mysql-database.php └── readme.rst ├── php-bulk-images-resize ├── images │ ├── abstract-business-code-coding-276452.jpg │ ├── accounting-analytics-balance-black-and-white-209224.jpg │ ├── adult-african-american-woman-business-city-1181341.jpg │ ├── adult-books-business-coffee-374016.jpg │ ├── analog-camera-behind-computer-laptop-3773401.jpg │ ├── app-business-connection-device-221185.jpg │ ├── app-entertainment-ipad-mockup-265685.jpg │ ├── apple-apple-device-design-desk-285814.jpg │ ├── apple-black-coffee-business-coffee-461064.jpg │ ├── apple-blank-business-computer-442574.jpg │ ├── apple-coffee-computer-cup-459653.jpg │ ├── apple-computer-decor-design-326502.jpg │ ├── apple-computer-desk-devices-326501.jpg │ ├── apple-magic-keyboard-with-numeric-pad-on-table-near-wireless-1714205.jpg │ ├── background-balance-business-commerce-583846.jpg │ ├── background-business-computer-connection-303383.jpg │ ├── beverage-break-breakfast-brown-414630.jpg │ ├── black-and-white-browsing-business-coffee-265152.jpg │ ├── black-blue-and-red-graph-illustration-186461.jpg │ ├── black-business-computer-contemporary-296115.jpg │ ├── black-computer-keyboard-on-black-table-3815729.jpg │ ├── black-laptop-computer-1122528.jpg │ ├── black-laptop-on-bed-3568792.jpg │ ├── blank-composition-desk-display-317355.jpg │ ├── blogging-blur-business-communication-261662.jpg │ ├── blue-close-up-computer-computer-keyboard-265631.jpg │ ├── blur-bright-business-codes-207580.jpg │ ├── board-2450236__480.jpg │ ├── chair-computer-furniture-indoors-373883.jpg │ ├── chart-close-up-coffee-cup-590037.jpg │ ├── chris-ried-ieic5Tq8YMk-unsplash.jpg │ ├── close-up-of-computer-keyboard-249203.jpg │ ├── code-coder-coding-computer-270404.jpg │ ├── coffee-cup-desk-earphone-317377.jpg │ ├── computer-connection-earphone-electronics-414548.jpg │ ├── computer-content-control-data-270700.jpg │ ├── computer-desk-electronics-indoors-374074.jpg │ ├── computer-device-earphones-electronics-583842.jpg │ ├── cup-of-fresh-cappuccino-near-laptop-keyboard-and-notebook-414645.jpg │ ├── design-desk-display-eyewear-313690.jpg │ ├── desktop-computer-beside-analog-camera-3759101.jpg │ ├── faisal-m-BI465ksrlWs-unsplash.jpg │ ├── faisal-m-g0RtZc1IBtU-unsplash.jpg │ ├── fashion-art-coffee-macbook-pro-57690.jpg │ ├── female-software-engineer-coding-on-computer-3861972.jpg │ ├── green-ceramic-mug-filled-with-black-coffee-3773835.jpg │ ├── greg-rakozy-vw3Ahg4x1tY-unsplash.jpg │ ├── group-of-person-sitting-indoors-3184306.jpg │ ├── high-angle-view-of-coffee-cup-on-table-317385.jpg │ ├── houses-businessman-man-hands-110469.jpg │ ├── information-sign-on-paper-317356.jpg │ ├── information-sign-on-shelf-251225.jpg │ ├── internet-technology-computer-display-360591.jpg │ ├── iphone-dark-notebook-pen-34140.jpg │ ├── laptop-beside-peach-color-wall-3759099.jpg │ ├── laptop-macbook-pro-office-computer-18105.jpg │ ├── light-smartphone-macbook-mockup-67112.jpg │ ├── macbook-air-beside-notebook-and-camera-916335.jpg │ ├── macbook-pro-92904.jpg │ ├── macbook-pro-on-black-table-3787591.jpg │ ├── macbook-pro-on-brown-wooden-table-3815750.jpg │ ├── macbook-pro-on-white-table-3787308.jpg │ ├── macbook-pro-on-white-table-3787830.jpg │ ├── macbook-pro-on-white-table-3787903.jpg │ ├── macbook-pro-on-white-table-3816195.jpg │ ├── man-in-black-shirt-sitting-in-front-of-computer-3861959.jpg │ ├── man-using-stylus-pen-for-touching-the-digital-tablet-screen-6335.jpg │ ├── marketing-iphone-smartphone-notebook-34069.jpg │ ├── markus-winkler-Xr1Lwph6eGI-unsplash.jpg │ ├── notebook-and-pen-beside-red-mug-on-gray-surface-3774057.jpg │ ├── pens-near-keyboard-and-paper-clips-1558690.jpg │ ├── person-in-blue-denim-jeans-using-laptop-3987110.jpg │ ├── person-in-front-of-laptop-on-brown-wooden-table-2115217.jpg │ ├── person-looking-at-phone-and-at-macbook-pro-1181244.jpg │ ├── person-touching-open-macbook-on-table-839465.jpg │ ├── person-using-laptop-computer-during-daytime-196655.jpg │ ├── person-using-silver-macbook-pro-1181467.jpg │ ├── person-writing-on-notebook-4144923.jpg │ ├── person-writing-on-white-paper-3803252.jpg │ ├── person-writing-on-white-paper-3815585.jpg │ ├── photo-of-imac-near-macbook-1029757.jpg │ ├── photo-of-laptop-beside-white-mug-1833306.jpg │ ├── photo-of-laptop-on-white-table-3787324.jpg │ ├── photo-of-macbook-pro-near-iphone-and-apple-magic-keyboard-2528116.jpg │ ├── photo-of-people-having-meeting-3183186.jpg │ ├── photo-of-woman-lying-on-bed-while-using-laptop-4066041.jpg │ ├── photography-of-laptop-in-a-dark-area-986774.jpg │ ├── shallow-focus-photography-of-macbook-792199.jpg │ ├── silver-imac-near-white-ceramic-kettle-205316.jpg │ ├── silver-laptop-beside-analog-camera-and-camera-lens-3759108.jpg │ ├── silver-laptop-in-white-wooden-table-3759098.jpg │ ├── silver-macbook-pro-on-tabletop-1967535.jpg │ ├── sincerely-media-CWL6tTDN31w-unsplash.jpg │ ├── space-grey-ipad-air-with-graph-on-brown-wooden-table-187041.jpg │ ├── technology-computer-desktop-programming-113850.jpg │ ├── top-view-of-assorted-gadgets-on-desk-3568520.jpg │ ├── top-view-of-people-at-the-meeting-3184287.jpg │ ├── top-view-photo-of-girl-watching-through-imac-4144294.jpg │ ├── top-view-photo-of-keyboard-near-earphones-1420701.jpg │ ├── top-view-photo-of-people-having-a-meeting-3183165.jpg │ ├── white-ceramic-mug-beside-spiral-notebook-and-laptop-3773413.jpg │ ├── white-paper-on-laptop-computer-2903063.jpg │ ├── white-round-table-beside-glass-window-3773397.jpg │ ├── white-smartphone-near-black-keyboard-3821159.jpg │ ├── woman-in-grey-jacket-sits-on-bed-uses-grey-laptop-935743.jpg │ ├── woman-in-white-tank-top-using-black-laptop-computer-with-vr-3861458.jpg │ ├── woman-writing-on-a-notebook-beside-teacup-and-tablet-733856.jpg │ ├── women-holding-space-gray-iphone-x-and-black-pen-744461.jpg │ ├── working-woman-person-technology-7375.jpg │ └── working-woman-technology-computer-7374.jpg ├── php-bulk-images-resize.php └── readme.rst ├── php-csv-json ├── php-csv-json.php ├── readme.rst ├── student.csv └── student.json ├── php-dependent-dropdown ├── category.sql ├── config.php ├── database.php ├── dependent-dropdown.php └── readme.rst ├── php-download-large-file ├── download-large-file.php └── readme.rst ├── php-email-validation ├── php-email-validation.php └── readme.rst ├── php-file-mime ├── php-file-mime.php └── readme.rst ├── php-file-read-last-n-lines ├── license.txt ├── php-file-read-last-n-lines.php └── readme.rst ├── php-files-upload-save-mysql ├── php-files-upload-save-mysql.php └── readme.rst ├── php-force-download-file ├── common.php ├── pclzip.lib.php ├── php-force-download-file.php └── readme.rst ├── php-generate-months ├── php-generate-months.php └── readme.rst ├── php-generate-years ├── php-generate-years.php └── readme.rst ├── php-josephus ├── php-josephus.php └── readme.rst ├── php-json-csv ├── php-json-csv.php ├── readme.rst ├── student.csv └── student.json ├── php-multiple-files-upload ├── files_upload.php └── readme.rst ├── php-mysql-download-file ├── db_config.php ├── download.php ├── file.sql ├── index.php └── readme.rst ├── php-mysql-infinite-level-nested-category ├── category.sql ├── php-mysql-infinite-level-nested-category.php └── readme.rst ├── php-mysql-login-logout-remember-me ├── common.php ├── config.php ├── database.php ├── home.php ├── login.php ├── logout.php ├── readme.rst └── user_account.sql ├── php-mysql-view-file ├── db_config.php ├── index.php ├── readme.rst └── view.php ├── php-nested-comments ├── add_comment.php ├── comments.css ├── comments.php ├── comments_blog.js ├── config.php ├── database.php ├── helper.php ├── index.php ├── jquery-1.9.1.min.js ├── jquery-migrate-1.2.1.js ├── jquery-ui-1.10.3-custom.min.js ├── jquery.blockUI-2.70.0.js ├── jquery.blockUI.js └── readme.rst ├── php-os-detection ├── php-os-detection.php └── readme.rst ├── php-past-future-date ├── php-past-future-date.php └── readme.rst ├── php-pdo-mysql-rest-api-crud ├── config │ └── db.php ├── department │ ├── create.php │ ├── delete.php │ ├── read.php │ └── update.php ├── object │ └── department.php ├── readme.rst └── rest-client │ ├── crud-operations.php │ └── rest-client.php ├── php-pretty-print-json ├── input.json ├── output.json ├── php-pretty-print-json.php └── readme.rst ├── php-read-write-csv-file ├── php-read-write-csv-file.php ├── read.csv ├── readme.rst └── write.csv ├── php-rest-api-multiple-files-upload ├── client │ └── php-files-upload-rest-client.php ├── readme.rst └── server │ └── php-rest-api-files-upload.php ├── php-rest-api-single-file-upload ├── client │ └── php-file-upload-rest-client.php ├── readme.rst └── server │ └── php-rest-api-file-upload.php ├── php-save-file-mysql ├── db_config.php ├── file.sql ├── index.php ├── readme.rst ├── upload.php └── utils.php ├── php-session-expiry-message ├── home.php ├── login.php ├── logout.php └── readme.rst ├── php-single-file-upload ├── file_upload.php └── readme.rst ├── php-sri-hash-generator ├── php-sri-hash-generator.php ├── readme.rst └── sample.js └── php-time-ago-or-time-to-go ├── readme.rst └── time-ago-or-time-to-go.php /README.md: -------------------------------------------------------------------------------- 1 | # php 2 | Source code in PHP programming 3 | -------------------------------------------------------------------------------- /php-ajax-jquery-multiple-files-upload/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 33 | 34 | 35 |

36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /php-ajax-jquery-multiple-files-upload/php-multiple-files-upload.php: -------------------------------------------------------------------------------- 1 | 0) { 7 | echo "Error: " . $_FILES["files"]["error"][$i] . "
"; 8 | } else { 9 | if (file_exists('uploads/' . $_FILES["files"]["name"][$i])) { 10 | echo 'File already exists : uploads/' . $_FILES["files"]["name"][$i]; 11 | } else { 12 | move_uploaded_file($_FILES["files"]["tmp_name"][$i], 'uploads/' . $_FILES["files"]["name"][$i]); 13 | echo 'File successfully uploaded : uploads/' . $_FILES["files"]["name"][$i] . ' '; 14 | } 15 | } 16 | } 17 | } else { 18 | echo 'Please choose at least one file'; 19 | } 20 | 21 | /* 22 | * End of script 23 | */ -------------------------------------------------------------------------------- /php-ajax-jquery-multiple-files-upload/readme.rst: -------------------------------------------------------------------------------- 1 | You can read tutorial at https://roytuts.com/ajax-multiple-files-upload-using-php-jquery/ -------------------------------------------------------------------------------- /php-ajax-jquery-multiple-rows-delete/assets/css/table.css: -------------------------------------------------------------------------------- 1 | table.datatable { 2 | width:100%; 3 | border: none; 4 | background:#fff; 5 | } 6 | table.datatable td.table_foot { 7 | border: none; 8 | background: #fff; 9 | text-align: center; 10 | } 11 | table.datatable tr.odd_col { 12 | background: none; 13 | } 14 | table.datatable tr.even_col { 15 | background: #ddd; 16 | } 17 | table.datatable td { 18 | font-size:10pt; 19 | padding:5px 10px; 20 | border-bottom:1px solid #ddd; 21 | text-align: left; 22 | } 23 | table.datatable th { 24 | text-align: left; 25 | font-size: 8pt; 26 | padding: 10px 10px 7px; 27 | text-transform: uppercase; 28 | color: #fff; 29 | background-color: black; 30 | font-family: sans-serif; 31 | } -------------------------------------------------------------------------------- /php-ajax-jquery-multiple-rows-delete/assets/js/app.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | //If check_all checked then check all table rows 3 | $("#check_all").on("click", function () { 4 | if ($("input:checkbox").prop("checked")) { 5 | $("input:checkbox[name='row-check']").prop("checked", true); 6 | } else { 7 | $("input:checkbox[name='row-check']").prop("checked", false); 8 | } 9 | }); 10 | 11 | // Check each table row checkbox 12 | $("input:checkbox[name='row-check']").on("change", function () { 13 | var total_check_boxes = $("input:checkbox[name='row-check']").length; 14 | var total_checked_boxes = $("input:checkbox[name='row-check']:checked").length; 15 | 16 | // If all checked manually then check check_all checkbox 17 | if (total_check_boxes === total_checked_boxes) { 18 | $("#check_all").prop("checked", true); 19 | } 20 | else { 21 | $("#check_all").prop("checked", false); 22 | } 23 | }); 24 | 25 | $("#delete_selected").on("click", function () { 26 | var ids = ''; 27 | var comma = ''; 28 | $("input:checkbox[name='row-check']:checked").each(function() { 29 | ids = ids + comma + this.value; 30 | comma = ','; 31 | }); 32 | 33 | if(ids.length > 0) { 34 | $.ajax({ 35 | type: "POST", 36 | url: "http://localhost/php-ajax-jquery-multiple-rows-delete/delete.php", 37 | data: JSON.stringify({'ids': ids}), 38 | dataType: "html", 39 | cache: false, 40 | success: function(msg) { 41 | $("#msg").html(msg); 42 | }, 43 | error: function(jqXHR, textStatus, errorThrown) { 44 | $("#msg").html("" + textStatus + " " + errorThrown + ""); 45 | } 46 | }); 47 | } else { 48 | $("#msg").html('You must select at least one product for deletion'); 49 | } 50 | }); 51 | }); -------------------------------------------------------------------------------- /php-ajax-jquery-multiple-rows-delete/db.php: -------------------------------------------------------------------------------- 1 | ids) . ")"; 17 | 18 | $result = dbQuery($sql); 19 | 20 | if($result) { 21 | echo 'Product(s) successfully deleted'; 22 | } else { 23 | echo 'Something went wrong during product deletion'; 24 | } 25 | } 26 | 27 | //End of file -------------------------------------------------------------------------------- /php-ajax-jquery-multiple-rows-delete/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Multiple Table Rows Deletion Example in PHP, AJAX, jQuery, MySQL 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 |

Multiple Table Rows Deletion Example in PHP, AJAX, jQuery, MySQL

14 | 15 |
16 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 53 | 54 |
IDCodeNamePrice
55 |

No Record Found

'; 58 | } 59 | ?> 60 |
61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /php-ajax-jquery-multiple-rows-delete/product.sql: -------------------------------------------------------------------------------- 1 | -- -------------------------------------------------------- 2 | -- Host: 127.0.0.1 3 | -- Server version: 8.0.17 - MySQL Community Server - GPL 4 | -- Server OS: Win64 5 | -- HeidiSQL Version: 10.2.0.5599 6 | -- -------------------------------------------------------- 7 | 8 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 9 | /*!40101 SET NAMES utf8 */; 10 | /*!50503 SET NAMES utf8mb4 */; 11 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 12 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 13 | 14 | 15 | -- Dumping database structure for roytuts 16 | CREATE DATABASE IF NOT EXISTS `roytuts` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci */ /*!80016 DEFAULT ENCRYPTION='N' */; 17 | USE `roytuts`; 18 | 19 | -- Dumping structure for table roytuts.product 20 | CREATE TABLE IF NOT EXISTS `product` ( 21 | `id` int(10) unsigned NOT NULL AUTO_INCREMENT, 22 | `name` varchar(255) NOT NULL, 23 | `code` varchar(255) NOT NULL, 24 | `price` double NOT NULL, 25 | PRIMARY KEY (`id`) 26 | ) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; 27 | 28 | -- Dumping data for table roytuts.product: ~11 rows (approximately) 29 | /*!40000 ALTER TABLE `product` DISABLE KEYS */; 30 | INSERT INTO `product` (`id`, `name`, `code`, `price`) VALUES 31 | (1, 'American Tourist', 'AMTR01', 12000), 32 | (2, 'EXP Portable Hard Drive', 'USB02', 5000), 33 | (3, 'Shoes', 'SH03', 1000), 34 | (4, 'XP 1155 Intel Core Laptop', 'LPN4', 80000), 35 | (5, 'FinePix Pro2 3D Camera', '3DCAM01', 150000), 36 | (6, 'Simple Mobile', 'MB06', 3000), 37 | (7, 'Luxury Ultra thin Wrist Watch', 'WristWear03', 3000), 38 | (8, 'Headphone', 'HD08', 400), 39 | (9, 'Test 1', 'test1', 10), 40 | (10, 'Test 2', 'test2', 11), 41 | (11, 'Test 3', 'test3', 12); 42 | /*!40000 ALTER TABLE `product` ENABLE KEYS */; 43 | 44 | /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; 45 | /*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; 46 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 47 | -------------------------------------------------------------------------------- /php-ajax-jquery-multiple-rows-delete/readme.rst: -------------------------------------------------------------------------------- 1 | Please follow the tutorial at https://roytuts.com/delete-multiple-rows-from-table-using-php-mysql-ajax-jquery 2 | -------------------------------------------------------------------------------- /php-ajax-jquery-mysql-crud/ajax_crud.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | PHP REST API MySQL AJAX jQuery CRUD 5 | 6 | 7 | 33 | 130 | 131 | 132 | 133 |

PHP REST API MySQL AJAX jQuery CRUD

134 | 135 |

Add a New Company

136 |
137 | 138 | 139 |
140 |
141 | 142 |
143 | 144 |

145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 |
IdNameActions
153 | 154 | 155 | -------------------------------------------------------------------------------- /php-ajax-jquery-mysql-crud/create.php: -------------------------------------------------------------------------------- 1 | name) . "')"; 17 | dbQuery($sql); 18 | } 19 | 20 | //End of file -------------------------------------------------------------------------------- /php-ajax-jquery-mysql-crud/db.php: -------------------------------------------------------------------------------- 1 | name) . "' WHERE id = " . $data->id; 17 | dbQuery($sql); 18 | } 19 | 20 | //End of file -------------------------------------------------------------------------------- /php-ajax-mysql-username-availability-check/auth.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Check username availability using PHP, AJAX, MySQL 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

14 |

PHP, AJAX, MySQL - username availability check

15 | 16 |
17 |
18 | Check username 19 |
20 |
21 | 22 |
23 |
24 |
25 |
26 |
27 | 28 | 29 | 57 | 58 | -------------------------------------------------------------------------------- /php-ajax-mysql-username-availability-check/db.php: -------------------------------------------------------------------------------- 1 | 0) { 12 | echo 'Username unavailable'; 13 | } else { 14 | echo 'Username available'; 15 | } 16 | 17 | closeConn(); 18 | } else { 19 | echo 'Username is required field.'; 20 | } -------------------------------------------------------------------------------- /php-ajax-mysql-username-availability-check/readme.rst: -------------------------------------------------------------------------------- 1 | You can go through the tutorial https://roytuts.com/username-availability-check-using-php-ajax-and-mysql/ 2 | -------------------------------------------------------------------------------- /php-ajax-mysql-username-availability-check/user.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `user` ( 2 | `user_id` int unsigned COLLATE utf8mb4_unicode_ci NOT NULL AUTO_INCREMENT, 3 | `login_username` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, 4 | `login_password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, 5 | `last_login` timestamp NULL DEFAULT CURRENT_TIMESTAMP, 6 | PRIMARY KEY (`user_id`), 7 | UNIQUE KEY `login_email_UNIQUE` (`login_username`) 8 | ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; 9 | 10 | insert into `user`(`user_id`,`login_username`,`login_password`,`last_login`) 11 | values (1,'user1','$2a$08$S5IfrpOVOvFbbOSOmZpjsO5N9PXgEerTloK','2014-07-19 19:18:30'),(2,'user2','$2a$08$v1kJflweCK3FOcoAsmYAUCMxFa5Shh7c2','2013-11-17 19:22:46'); -------------------------------------------------------------------------------- /php-ajax-single-file-upload/ajax_file_upload.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PHP AJAX Single File Upload Example 6 | 7 | 8 | 32 | 33 | 34 |

Single File Upload Example using PHP

35 |

36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /php-ajax-single-file-upload/readme.rst: -------------------------------------------------------------------------------- 1 | You can read tutorial https://roytuts.com/ajax-file-upload-using-php-jquery/ -------------------------------------------------------------------------------- /php-ajax-single-file-upload/upload.php: -------------------------------------------------------------------------------- 1 | Error during file upload ' . $_FILES['file']['error'] . ''; 5 | } else { 6 | if (file_exists('uploads/' . $_FILES['file']['name'])) { 7 | echo 'File already exists at uploads/' . $_FILES['file']['name'] . ''; 8 | } else { 9 | move_uploaded_file($_FILES['file']['tmp_name'], 'uploads/' . $_FILES['file']['name']); 10 | echo 'File successfully uploaded to uploads/' . $_FILES['file']['name'] . ''; 11 | } 12 | } 13 | } else { 14 | echo 'Please choose a file'; 15 | } 16 | echo nl2br("\n"); 17 | ?> -------------------------------------------------------------------------------- /php-backup-mysql-database/common.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |

Starting MySQL Database Backup

12 | 15 |

Database Backup Successfully Done

16 | 17 | -------------------------------------------------------------------------------- /php-backup-mysql-database/readme.rst: -------------------------------------------------------------------------------- 1 | You can read tutorial https://roytuts.com/database-backup-using-php/ -------------------------------------------------------------------------------- /php-bulk-images-resize/images/abstract-business-code-coding-276452.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/abstract-business-code-coding-276452.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/accounting-analytics-balance-black-and-white-209224.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/accounting-analytics-balance-black-and-white-209224.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/adult-african-american-woman-business-city-1181341.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/adult-african-american-woman-business-city-1181341.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/adult-books-business-coffee-374016.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/adult-books-business-coffee-374016.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/analog-camera-behind-computer-laptop-3773401.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/analog-camera-behind-computer-laptop-3773401.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/app-business-connection-device-221185.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/app-business-connection-device-221185.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/app-entertainment-ipad-mockup-265685.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/app-entertainment-ipad-mockup-265685.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/apple-apple-device-design-desk-285814.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/apple-apple-device-design-desk-285814.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/apple-black-coffee-business-coffee-461064.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/apple-black-coffee-business-coffee-461064.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/apple-blank-business-computer-442574.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/apple-blank-business-computer-442574.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/apple-coffee-computer-cup-459653.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/apple-coffee-computer-cup-459653.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/apple-computer-decor-design-326502.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/apple-computer-decor-design-326502.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/apple-computer-desk-devices-326501.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/apple-computer-desk-devices-326501.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/apple-magic-keyboard-with-numeric-pad-on-table-near-wireless-1714205.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/apple-magic-keyboard-with-numeric-pad-on-table-near-wireless-1714205.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/background-balance-business-commerce-583846.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/background-balance-business-commerce-583846.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/background-business-computer-connection-303383.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/background-business-computer-connection-303383.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/beverage-break-breakfast-brown-414630.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/beverage-break-breakfast-brown-414630.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/black-and-white-browsing-business-coffee-265152.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/black-and-white-browsing-business-coffee-265152.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/black-blue-and-red-graph-illustration-186461.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/black-blue-and-red-graph-illustration-186461.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/black-business-computer-contemporary-296115.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/black-business-computer-contemporary-296115.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/black-computer-keyboard-on-black-table-3815729.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/black-computer-keyboard-on-black-table-3815729.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/black-laptop-computer-1122528.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/black-laptop-computer-1122528.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/black-laptop-on-bed-3568792.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/black-laptop-on-bed-3568792.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/blank-composition-desk-display-317355.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/blank-composition-desk-display-317355.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/blogging-blur-business-communication-261662.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/blogging-blur-business-communication-261662.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/blue-close-up-computer-computer-keyboard-265631.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/blue-close-up-computer-computer-keyboard-265631.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/blur-bright-business-codes-207580.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/blur-bright-business-codes-207580.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/board-2450236__480.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/board-2450236__480.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/chair-computer-furniture-indoors-373883.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/chair-computer-furniture-indoors-373883.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/chart-close-up-coffee-cup-590037.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/chart-close-up-coffee-cup-590037.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/chris-ried-ieic5Tq8YMk-unsplash.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/chris-ried-ieic5Tq8YMk-unsplash.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/close-up-of-computer-keyboard-249203.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/close-up-of-computer-keyboard-249203.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/code-coder-coding-computer-270404.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/code-coder-coding-computer-270404.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/coffee-cup-desk-earphone-317377.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/coffee-cup-desk-earphone-317377.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/computer-connection-earphone-electronics-414548.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/computer-connection-earphone-electronics-414548.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/computer-content-control-data-270700.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/computer-content-control-data-270700.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/computer-desk-electronics-indoors-374074.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/computer-desk-electronics-indoors-374074.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/computer-device-earphones-electronics-583842.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/computer-device-earphones-electronics-583842.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/cup-of-fresh-cappuccino-near-laptop-keyboard-and-notebook-414645.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/cup-of-fresh-cappuccino-near-laptop-keyboard-and-notebook-414645.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/design-desk-display-eyewear-313690.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/design-desk-display-eyewear-313690.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/desktop-computer-beside-analog-camera-3759101.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/desktop-computer-beside-analog-camera-3759101.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/faisal-m-BI465ksrlWs-unsplash.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/faisal-m-BI465ksrlWs-unsplash.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/faisal-m-g0RtZc1IBtU-unsplash.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/faisal-m-g0RtZc1IBtU-unsplash.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/fashion-art-coffee-macbook-pro-57690.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/fashion-art-coffee-macbook-pro-57690.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/female-software-engineer-coding-on-computer-3861972.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/female-software-engineer-coding-on-computer-3861972.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/green-ceramic-mug-filled-with-black-coffee-3773835.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/green-ceramic-mug-filled-with-black-coffee-3773835.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/greg-rakozy-vw3Ahg4x1tY-unsplash.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/greg-rakozy-vw3Ahg4x1tY-unsplash.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/group-of-person-sitting-indoors-3184306.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/group-of-person-sitting-indoors-3184306.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/high-angle-view-of-coffee-cup-on-table-317385.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/high-angle-view-of-coffee-cup-on-table-317385.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/houses-businessman-man-hands-110469.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/houses-businessman-man-hands-110469.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/information-sign-on-paper-317356.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/information-sign-on-paper-317356.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/information-sign-on-shelf-251225.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/information-sign-on-shelf-251225.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/internet-technology-computer-display-360591.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/internet-technology-computer-display-360591.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/iphone-dark-notebook-pen-34140.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/iphone-dark-notebook-pen-34140.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/laptop-beside-peach-color-wall-3759099.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/laptop-beside-peach-color-wall-3759099.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/laptop-macbook-pro-office-computer-18105.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/laptop-macbook-pro-office-computer-18105.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/light-smartphone-macbook-mockup-67112.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/light-smartphone-macbook-mockup-67112.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/macbook-air-beside-notebook-and-camera-916335.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/macbook-air-beside-notebook-and-camera-916335.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/macbook-pro-92904.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/macbook-pro-92904.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/macbook-pro-on-black-table-3787591.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/macbook-pro-on-black-table-3787591.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/macbook-pro-on-brown-wooden-table-3815750.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/macbook-pro-on-brown-wooden-table-3815750.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/macbook-pro-on-white-table-3787308.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/macbook-pro-on-white-table-3787308.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/macbook-pro-on-white-table-3787830.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/macbook-pro-on-white-table-3787830.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/macbook-pro-on-white-table-3787903.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/macbook-pro-on-white-table-3787903.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/macbook-pro-on-white-table-3816195.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/macbook-pro-on-white-table-3816195.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/man-in-black-shirt-sitting-in-front-of-computer-3861959.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/man-in-black-shirt-sitting-in-front-of-computer-3861959.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/man-using-stylus-pen-for-touching-the-digital-tablet-screen-6335.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/man-using-stylus-pen-for-touching-the-digital-tablet-screen-6335.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/marketing-iphone-smartphone-notebook-34069.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/marketing-iphone-smartphone-notebook-34069.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/markus-winkler-Xr1Lwph6eGI-unsplash.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/markus-winkler-Xr1Lwph6eGI-unsplash.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/notebook-and-pen-beside-red-mug-on-gray-surface-3774057.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/notebook-and-pen-beside-red-mug-on-gray-surface-3774057.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/pens-near-keyboard-and-paper-clips-1558690.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/pens-near-keyboard-and-paper-clips-1558690.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/person-in-blue-denim-jeans-using-laptop-3987110.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/person-in-blue-denim-jeans-using-laptop-3987110.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/person-in-front-of-laptop-on-brown-wooden-table-2115217.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/person-in-front-of-laptop-on-brown-wooden-table-2115217.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/person-looking-at-phone-and-at-macbook-pro-1181244.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/person-looking-at-phone-and-at-macbook-pro-1181244.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/person-touching-open-macbook-on-table-839465.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/person-touching-open-macbook-on-table-839465.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/person-using-laptop-computer-during-daytime-196655.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/person-using-laptop-computer-during-daytime-196655.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/person-using-silver-macbook-pro-1181467.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/person-using-silver-macbook-pro-1181467.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/person-writing-on-notebook-4144923.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/person-writing-on-notebook-4144923.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/person-writing-on-white-paper-3803252.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/person-writing-on-white-paper-3803252.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/person-writing-on-white-paper-3815585.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/person-writing-on-white-paper-3815585.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/photo-of-imac-near-macbook-1029757.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/photo-of-imac-near-macbook-1029757.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/photo-of-laptop-beside-white-mug-1833306.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/photo-of-laptop-beside-white-mug-1833306.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/photo-of-laptop-on-white-table-3787324.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/photo-of-laptop-on-white-table-3787324.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/photo-of-macbook-pro-near-iphone-and-apple-magic-keyboard-2528116.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/photo-of-macbook-pro-near-iphone-and-apple-magic-keyboard-2528116.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/photo-of-people-having-meeting-3183186.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/photo-of-people-having-meeting-3183186.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/photo-of-woman-lying-on-bed-while-using-laptop-4066041.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/photo-of-woman-lying-on-bed-while-using-laptop-4066041.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/photography-of-laptop-in-a-dark-area-986774.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/photography-of-laptop-in-a-dark-area-986774.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/shallow-focus-photography-of-macbook-792199.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/shallow-focus-photography-of-macbook-792199.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/silver-imac-near-white-ceramic-kettle-205316.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/silver-imac-near-white-ceramic-kettle-205316.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/silver-laptop-beside-analog-camera-and-camera-lens-3759108.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/silver-laptop-beside-analog-camera-and-camera-lens-3759108.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/silver-laptop-in-white-wooden-table-3759098.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/silver-laptop-in-white-wooden-table-3759098.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/silver-macbook-pro-on-tabletop-1967535.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/silver-macbook-pro-on-tabletop-1967535.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/sincerely-media-CWL6tTDN31w-unsplash.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/sincerely-media-CWL6tTDN31w-unsplash.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/space-grey-ipad-air-with-graph-on-brown-wooden-table-187041.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/space-grey-ipad-air-with-graph-on-brown-wooden-table-187041.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/technology-computer-desktop-programming-113850.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/technology-computer-desktop-programming-113850.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/top-view-of-assorted-gadgets-on-desk-3568520.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/top-view-of-assorted-gadgets-on-desk-3568520.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/top-view-of-people-at-the-meeting-3184287.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/top-view-of-people-at-the-meeting-3184287.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/top-view-photo-of-girl-watching-through-imac-4144294.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/top-view-photo-of-girl-watching-through-imac-4144294.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/top-view-photo-of-keyboard-near-earphones-1420701.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/top-view-photo-of-keyboard-near-earphones-1420701.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/top-view-photo-of-people-having-a-meeting-3183165.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/top-view-photo-of-people-having-a-meeting-3183165.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/white-ceramic-mug-beside-spiral-notebook-and-laptop-3773413.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/white-ceramic-mug-beside-spiral-notebook-and-laptop-3773413.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/white-paper-on-laptop-computer-2903063.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/white-paper-on-laptop-computer-2903063.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/white-round-table-beside-glass-window-3773397.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/white-round-table-beside-glass-window-3773397.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/white-smartphone-near-black-keyboard-3821159.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/white-smartphone-near-black-keyboard-3821159.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/woman-in-grey-jacket-sits-on-bed-uses-grey-laptop-935743.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/woman-in-grey-jacket-sits-on-bed-uses-grey-laptop-935743.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/woman-in-white-tank-top-using-black-laptop-computer-with-vr-3861458.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/woman-in-white-tank-top-using-black-laptop-computer-with-vr-3861458.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/woman-writing-on-a-notebook-beside-teacup-and-tablet-733856.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/woman-writing-on-a-notebook-beside-teacup-and-tablet-733856.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/women-holding-space-gray-iphone-x-and-black-pen-744461.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/women-holding-space-gray-iphone-x-and-black-pen-744461.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/working-woman-person-technology-7375.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/working-woman-person-technology-7375.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/images/working-woman-technology-computer-7374.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/roytuts/php/c2416196e8edd178e1007659252d1b71d2bf5016/php-bulk-images-resize/images/working-woman-technology-computer-7374.jpg -------------------------------------------------------------------------------- /php-bulk-images-resize/php-bulk-images-resize.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /php-bulk-images-resize/readme.rst: -------------------------------------------------------------------------------- 1 | Please follow the tutorial https://roytuts.com/how-to-resize-bulk-images-using-php/ 2 | -------------------------------------------------------------------------------- /php-csv-json/php-csv-json.php: -------------------------------------------------------------------------------- 1 | $row_data) { 23 | // skip the first row, since it's the headers 24 | if($row_index === 0) continue; 25 | 26 | // iterate through each column in the row 27 | foreach ($row_data as $col_idx => $col_val) { 28 | 29 | // get the key for each entry 30 | $label = $headers[$col_idx]; 31 | 32 | // add this column's value to this row's index / column's key 33 | $json[$row_index][$label] = $col_val; 34 | } 35 | } 36 | 37 | //output as JSON string 38 | echo json_encode($json, JSON_PRETTY_PRINT); 39 | 40 | //write to JSON file 41 | $fp = fopen('student.json', 'w'); 42 | fwrite($fp, json_encode($json, JSON_PRETTY_PRINT)); 43 | fclose($fp); -------------------------------------------------------------------------------- /php-csv-json/readme.rst: -------------------------------------------------------------------------------- 1 | You can read tutorial https://roytuts.com/how-to-convert-csv-to-json-in-php/ -------------------------------------------------------------------------------- /php-csv-json/student.csv: -------------------------------------------------------------------------------- 1 | student_id,student_dob,student_email,student_address 2 | 1,01-01-1980,sumit@email.com,Garifa 3 | 2,01-01-1982,gourab@email.com,Garia 4 | 3,01-01-1982,debina@email.com,Salt Lake 5 | 4,01-01-1992,souvik@email.com,Alipore 6 | 5,01-01-1990,liton@email.com,Salt Lake -------------------------------------------------------------------------------- /php-csv-json/student.json: -------------------------------------------------------------------------------- 1 | { 2 | "1": { 3 | "student_id": "1", 4 | "student_dob": "01-01-1980", 5 | "student_email": "sumit@email.com", 6 | "student_address": "Garifa" 7 | }, 8 | "2": { 9 | "student_id": "2", 10 | "student_dob": "01-01-1982", 11 | "student_email": "gourab@email.com", 12 | "student_address": "Garia" 13 | }, 14 | "3": { 15 | "student_id": "3", 16 | "student_dob": "01-01-1982", 17 | "student_email": "debina@email.com", 18 | "student_address": "Salt Lake" 19 | }, 20 | "4": { 21 | "student_id": "4", 22 | "student_dob": "01-01-1992", 23 | "student_email": "souvik@email.com", 24 | "student_address": "Alipore" 25 | }, 26 | "5": { 27 | "student_id": "5", 28 | "student_dob": "01-01-1990", 29 | "student_email": "liton@email.com", 30 | "student_address": "Salt Lake" 31 | } 32 | } -------------------------------------------------------------------------------- /php-dependent-dropdown/category.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `category` ( 2 | `category_id` int unsigned COLLATE utf8mb4_unicode_ci NOT NULL AUTO_INCREMENT, 3 | `category_name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, 4 | `category_link` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, 5 | `parent_id` int unsigned COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0', 6 | `sort_order` int COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0', 7 | PRIMARY KEY (`category_id`), 8 | UNIQUE KEY `unique` (`category_name`) 9 | ) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; 10 | 11 | insert into `category`(`category_id`,`category_name`,`category_link`,`parent_id`,`sort_order`) values (1,'Home','home',0,0), 12 | (2,'Tutorials','tutorials',0,1), 13 | (3,'Java','java',2,1), 14 | (4,'Liferay','liferay',2,1), 15 | (5,'Frameworks','frameworks',0,2), 16 | (6,'JSF','jsf',5,2), 17 | (7,'Struts','struts',5,2), 18 | (8,'Spring','spring',5,2), 19 | (9,'Hibernate','hibernate',5,2), 20 | (10,'Webservices','webservices',0,3), 21 | (11,'REST','rest',10,3), 22 | (12,'SOAP','soap',10,3), 23 | (13,'Contact','contact',0,4), 24 | (14,'About','about',0,5); -------------------------------------------------------------------------------- /php-dependent-dropdown/config.php: -------------------------------------------------------------------------------- 1 | ' . 'Subcategory Id: ' . $cmenu; 20 | } else if (isset($_POST['ccat'])) { 21 | echo 'Parent Cat Id: ' . $pmenu; 22 | } 23 | } 24 | ?> 25 | 26 | 27 | 28 | 29 | 30 | Dependent dropdown in PHP, MySQL 31 | 45 | 46 | 47 | 50 |
51 |
52 |
53 |

54 | 55 | 56 | 67 |

68 | 0) { 75 | ?> 76 |

77 | 78 | 87 |

88 | 92 |

93 |
94 |
95 |
96 | 97 | -------------------------------------------------------------------------------- /php-dependent-dropdown/readme.rst: -------------------------------------------------------------------------------- 1 | You can go through the tutorial https://roytuts.com/dependent-dropdown-example-in-php-mysql/ 2 | -------------------------------------------------------------------------------- /php-download-large-file/download-large-file.php: -------------------------------------------------------------------------------- 1 | array( 26 | "verify_peer"=>false, 27 | "verify_peer_name"=>false, 28 | ), 29 | ); 30 | 31 | $context = stream_context_create($options); 32 | 33 | //$handle = fopen($path, 'rb'); 34 | $handle = fopen($path, 'rb', false, $context); 35 | 36 | ob_end_clean();//output buffering is disabled, so you won't hit your memory limit 37 | 38 | //$newfname = basename($path); 39 | //$newf = fopen ($newfname, "wb"); 40 | 41 | $chunkSize = 1024 * 1024; 42 | $buffer = ''; 43 | 44 | ob_start(); 45 | while (!feof($handle)) { 46 | $buffer = fread($handle, $chunkSize); 47 | echo $buffer; 48 | ob_flush(); 49 | flush(); 50 | 51 | //fwrite($newf, $buffer, $chunkSize); 52 | } 53 | 54 | fclose($handle); 55 | 56 | //fclose($newf); 57 | 58 | exit; 59 | } 60 | 61 | //Download File 62 | download_file_chunked('https://research.nhm.org/pdfs/10840/10840.pdf'); 63 | 64 | function download_large_file($path) { 65 | // the file name of the download, change this if needed 66 | $file_name = basename($path); 67 | 68 | // get the file's mime type to send the correct content type header 69 | //$finfo = finfo_open(FILEINFO_MIME_TYPE); //For remote file, it may not work 70 | //$mime_type = finfo_file($finfo, $path); //For remote file, it may not work 71 | $mime_type = mime_type($file_name); 72 | 73 | $attachment = (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) ? "" : " attachment"; // IE 5.5 fix. 74 | 75 | // send the headers 76 | header("Content-Type: $mime_type"); 77 | //header('Content-Length: ' . filesize($path)); //PHP Warning: filesize(): stat failed for remote file 78 | //header("Content-Disposition: attachment; filename=$file_name;"); 79 | header("Content-Disposition: $attachment; filename=$file_name;"); 80 | 81 | //Disable SSL verification 82 | $options=array( 83 | "ssl"=>array( 84 | "verify_peer"=>false, 85 | "verify_peer_name"=>false, 86 | ), 87 | ); 88 | 89 | $context = stream_context_create($options); 90 | 91 | // stream the file 92 | //$fp = fopen($path, 'rb'); 93 | $fp = fopen($path, 'rb', false, $context); 94 | 95 | ob_end_clean();//output buffering is disabled, so you won't hit your memory limit 96 | 97 | fpassthru($fp); 98 | 99 | fclose($fp); 100 | 101 | exit; 102 | } 103 | 104 | //download_large_file('https://research.nhm.org/pdfs/10840/10840.pdf'); 105 | 106 | function mime_type($filename) { 107 | 108 | $mime_types = array( 109 | 110 | 'txt' => 'text/plain', 111 | 'htm' => 'text/html', 112 | 'html' => 'text/html', 113 | 'php' => 'text/html', 114 | 'css' => 'text/css', 115 | 'js' => 'application/javascript', 116 | 'json' => 'application/json', 117 | 'xml' => 'application/xml', 118 | 'swf' => 'application/x-shockwave-flash', 119 | 'flv' => 'video/x-flv', 120 | 121 | // images 122 | 'png' => 'image/png', 123 | 'jpe' => 'image/jpeg', 124 | 'jpeg' => 'image/jpeg', 125 | 'jpg' => 'image/jpeg', 126 | 'gif' => 'image/gif', 127 | 'bmp' => 'image/bmp', 128 | 'ico' => 'image/vnd.microsoft.icon', 129 | 'tiff' => 'image/tiff', 130 | 'tif' => 'image/tiff', 131 | 'svg' => 'image/svg+xml', 132 | 'svgz' => 'image/svg+xml', 133 | 134 | // archives 135 | 'zip' => 'application/zip', 136 | 'rar' => 'application/x-rar-compressed', 137 | 'exe' => 'application/x-msdownload', 138 | 'msi' => 'application/x-msdownload', 139 | 'cab' => 'application/vnd.ms-cab-compressed', 140 | 141 | // audio/video 142 | 'mp3' => 'audio/mpeg', 143 | 'qt' => 'video/quicktime', 144 | 'mov' => 'video/quicktime', 145 | 146 | // adobe 147 | 'pdf' => 'application/pdf', 148 | 'psd' => 'image/vnd.adobe.photoshop', 149 | 'ai' => 'application/postscript', 150 | 'eps' => 'application/postscript', 151 | 'ps' => 'application/postscript', 152 | 153 | // ms office 154 | 'doc' => 'application/msword', 155 | 'rtf' => 'application/rtf', 156 | 'xls' => 'application/vnd.ms-excel', 157 | 'ppt' => 'application/vnd.ms-powerpoint', 158 | 159 | // open office 160 | 'odt' => 'application/vnd.oasis.opendocument.text', 161 | 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', 162 | ); 163 | 164 | $tmp = explode('.',$filename); 165 | $ext = strtolower(end($tmp)); 166 | 167 | if (array_key_exists($ext, $mime_types)) { 168 | return $mime_types[$ext]; 169 | }else if (function_exists('finfo_open')) { 170 | $finfo = finfo_open(FILEINFO_MIME); 171 | $mimetype = finfo_file($finfo, $filename); 172 | finfo_close($finfo); 173 | return $mimetype; 174 | } else { 175 | return 'application/octet-stream'; 176 | } 177 | } -------------------------------------------------------------------------------- /php-download-large-file/readme.rst: -------------------------------------------------------------------------------- 1 | You can go through the tutorial https://roytuts.com/php-large-file-download-in-chunks/ -------------------------------------------------------------------------------- /php-email-validation/php-email-validation.php: -------------------------------------------------------------------------------- 1 | 332 | Copyright (C) 333 | 334 | This program is free software; you can redistribute it and/or modify 335 | it under the terms of the GNU General Public License as published by 336 | the Free Software Foundation; either version 2 of the License, or 337 | (at your option) any later version. 338 | 339 | This program is distributed in the hope that it will be useful, 340 | but WITHOUT ANY WARRANTY; without even the implied warranty of 341 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 342 | GNU General Public License for more details. 343 | 344 | You should have received a copy of the GNU General Public License along 345 | with this program; if not, write to the Free Software Foundation, Inc., 346 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 347 | 348 | Also add information on how to contact you by electronic and paper mail. 349 | 350 | If the program is interactive, make it output a short notice like this 351 | when it starts in an interactive mode: 352 | 353 | Gnomovision version 69, Copyright (C) year name of author 354 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 355 | This is free software, and you are welcome to redistribute it 356 | under certain conditions; type `show c' for details. 357 | 358 | The hypothetical commands `show w' and `show c' should show the appropriate 359 | parts of the General Public License. Of course, the commands you use may 360 | be called something other than `show w' and `show c'; they could even be 361 | mouse-clicks or menu items--whatever suits your program. 362 | 363 | You should also get your employer (if you work as a programmer) or your 364 | school, if any, to sign a "copyright disclaimer" for the program, if 365 | necessary. Here is a sample; alter the names: 366 | 367 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 368 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 369 | 370 | , 1 April 1989 371 | Ty Coon, President of Vice 372 | 373 | This General Public License does not permit incorporating your program into 374 | proprietary programs. If your program is a subroutine library, you may 375 | consider it more useful to permit linking proprietary applications with the 376 | library. If this is what you want to do, use the GNU Lesser General 377 | Public License instead of this License. 378 | 379 | WRITTEN OFFER 380 | 381 | The source code for any program binaries or compressed scripts that are 382 | included with WordPress can be freely obtained at the following URL: 383 | 384 | https://wordpress.org/download/source/ 385 | -------------------------------------------------------------------------------- /php-file-read-last-n-lines/php-file-read-last-n-lines.php: -------------------------------------------------------------------------------- 1 | 0) { 7 | for ($i = $readLines; $i < count($file); $i++) { 8 | echo $file[$i]; 9 | echo nl2br("\n"); 10 | } 11 | } else { 12 | echo 'file does not have required no. of lines to read'; 13 | }*/ 14 | 15 | $file = new SplFileObject('license.txt', 'r'); 16 | $file->seek(PHP_INT_MAX); 17 | $last_line = $file->key(); 18 | $lines = new LimitIterator($file, $last_line - 10, $last_line); //n being non-zero positive integer 19 | print_r(iterator_to_array($lines)); 20 | 21 | // Iterate each element 22 | /*$it = iterator_to_array($lines); 23 | 24 | foreach($it as $ele){ 25 | echo nl2br($ele . "\n"); 26 | }*/ 27 | 28 | 29 | ?> -------------------------------------------------------------------------------- /php-file-read-last-n-lines/readme.rst: -------------------------------------------------------------------------------- 1 | Please follow the tutorial https://roytuts.com/how-to-read-last-n-lines-from-a-file-in-php/ 2 | -------------------------------------------------------------------------------- /php-files-upload-save-mysql/php-files-upload-save-mysql.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Files Save into MySQL Database using PHP 6 | 33 | 34 | 35 | 36 | 37 | $value) { 43 | if (0 < $value['error']) { 44 | echo 'Error during file upload ' . $value['error']; 45 | } else if (!empty($value['name'])) { 46 | $dbConn = mysqli_connect('localhost', 'root', 'root', 'roytuts') or die('MySQL connect failed. ' . mysqli_connect_error()); 47 | 48 | $sql = "insert into files_data(name, type, size, content, saved_date) values('".$value['name']."', '".$value['type']."', '".filesize_formatted($value['size'])."', '".mysqli_escape_string($dbConn, file_get_contents($value['tmp_name']))."', '".date('Y-m-d H:i:s')."')"; 49 | 50 | $result = mysqli_query($dbConn, $sql) or die(mysqli_error($dbConn)); 51 | 52 | if($result) { 53 | echo 'File successfully saved to database'; 54 | } 55 | } 56 | } 57 | } 58 | } 59 | 60 | function filesize_formatted($size) { 61 | $units = array( 'B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); 62 | $power = $size > 0 ? floor(log($size, 1024)) : 0; 63 | 64 | return number_format($size / pow(1024, $power), 2, '.', ',') . ' ' . $units[$power]; 65 | } 66 | ?> 67 |
68 |
69 |
70 | Files Save into MySQL database using PHP 71 |
72 | 73 | 76 |
77 |
78 | 81 |
82 |
83 |
 
84 |
85 | 86 |
87 |
88 |
89 | 90 | 91 | 92 | 104 | 105 | 122 | 123 | -------------------------------------------------------------------------------- /php-files-upload-save-mysql/readme.rst: -------------------------------------------------------------------------------- 1 | You can read tutorial https://roytuts.com/save-files-to-mysql-using-php/ -------------------------------------------------------------------------------- /php-force-download-file/common.php: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |

Force Download File

17 |
18 | 19 |
20 |
21 | 22 | -------------------------------------------------------------------------------- /php-force-download-file/readme.rst: -------------------------------------------------------------------------------- 1 | Please follow the tutorial https://roytuts.com/force-download-a-file-using-php/ 2 | -------------------------------------------------------------------------------- /php-generate-months/php-generate-months.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Dynamically Generate Months in PHP 6 | 7 | 8 |
'; 10 | echo 'echo generate_months();

'; 11 | echo generate_months(); 12 | 13 | /** 14 | * dynamically generate months dropdown 15 | * @param string $id id of the select-option 16 | * @return html 17 | */ 18 | function generate_months($id = 'month') { 19 | //start the select tag 20 | $html = '"; 30 | 31 | return $html; 32 | } 33 | ?> 34 | 35 | 36 | -------------------------------------------------------------------------------- /php-generate-months/readme.rst: -------------------------------------------------------------------------------- 1 | Please follow the tutorial https://roytuts.com/dynamically-generate-months-in-php/ 2 | -------------------------------------------------------------------------------- /php-generate-years/php-generate-years.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Dynamically Generate Years in PHP 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | '; 15 | echo '

default - last 10 years'; 16 | echo '
generate_years();'; 17 | echo '
'; 18 | echo generate_years(); 19 | echo ''; 20 | 21 | echo ''; 27 | 28 | echo ''; 34 | ?> 35 | 36 |
Usages of generate_years() function
'; 22 | echo 'generate from starting year 1990 to current year'; 23 | echo '
generate_years(\'year\', 1990);'; 24 | echo '
'; 25 | echo generate_years('year', 1990); 26 | echo '
'; 29 | echo 'generate from starting year 1990 to 2030'; 30 | echo '
generate_years(\'year\', 1990, 2030);'; 31 | echo '
'; 32 | echo generate_years('year', 1990, 2030); 33 | echo '
37 | 38 | trim($endYear)) { 60 | return 'Start Year cannot be greater than End Year!'; 61 | } 62 | 63 | //start the select tag 64 | $html = '"; 72 | 73 | return $html; 74 | } 75 | 76 | function holds_int($str) { 77 | return preg_match("/^[1-9][0-9]*$/", $str); 78 | } 79 | ?> 80 | 81 | 82 | -------------------------------------------------------------------------------- /php-generate-years/readme.rst: -------------------------------------------------------------------------------- 1 | Please follow the tutorial https://roytuts.com/dynamically-generate-years-in-php/ 2 | -------------------------------------------------------------------------------- /php-josephus/php-josephus.php: -------------------------------------------------------------------------------- 1 | 0) { 12 | unset($arr[$calRemPos]); 13 | 14 | $arr = array_values($arr); 15 | 16 | $calRemPos += $remStartPos - 1; 17 | if ($calRemPos > (count($arr) - 1)) { 18 | $calRemPos = $calRemPos % count($arr); 19 | } 20 | $iterations--; 21 | } 22 | return current($arr); 23 | } 24 | 25 | $winner = josephWinner(5, 3); 26 | echo ('winner is ' . $winner); 27 | echo nl2br("\n"); 28 | $winner = josephWinner(10, 3); 29 | echo ('winner is ' . $winner); 30 | echo nl2br("\n"); 31 | $winner = josephWinner(5, 2); 32 | echo ('winner is ' . $winner); 33 | echo nl2br("\n"); 34 | $winner = josephWinner(7, 3); 35 | echo ('winner is ' . $winner); 36 | echo nl2br("\n"); 37 | 38 | ?> 39 | -------------------------------------------------------------------------------- /php-josephus/readme.rst: -------------------------------------------------------------------------------- 1 | Please follow the tutorial https://roytuts.com/josephus-problem/ 2 | -------------------------------------------------------------------------------- /php-json-csv/php-json-csv.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Upload Multiple File(s) 6 | 24 | 25 | 26 | 27 | 28 | $value) { 34 | if (0 < $value['error']) { 35 | echo nl2br('Error during file upload ' . $value['error'] . "\n"); 36 | } else if (!empty($value['name'])) { 37 | if (file_exists('uploads/' . $value['name'])) { 38 | echo nl2br('Hey, File already exists at uploads/' . $value['name'] . "\n"); 39 | } else { 40 | move_uploaded_file($value['tmp_name'], 'uploads/' . $value['name']); 41 | echo nl2br('File successfully uploaded to uploads/' . $value['name'] . "\n"); 42 | } 43 | } 44 | } 45 | } 46 | } 47 | ?> 48 |
49 |
50 |
51 | Upload Multiple File(s) 52 |
53 | 54 | 57 |
58 |
59 | 62 |
63 |
64 |
 
65 |
66 | 67 |
68 |
69 |
70 | 71 | 72 | 73 | 85 | 86 | 100 | 101 | 109 | -------------------------------------------------------------------------------- /php-multiple-files-upload/readme.rst: -------------------------------------------------------------------------------- 1 | Please follow the tutorial https://roytuts.com/php-multiple-files-upload-example/ 2 | -------------------------------------------------------------------------------- /php-mysql-download-file/db_config.php: -------------------------------------------------------------------------------- 1 | connect_error) { 13 | die("Connection failed: " . $db->connect_error); 14 | } 15 | -------------------------------------------------------------------------------- /php-mysql-download-file/download.php: -------------------------------------------------------------------------------- 1 | query($query); 9 | 10 | list($id, $name, $content, $size, $type) = mysqli_fetch_array($result); 11 | 12 | header('Expires: 0'); 13 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 14 | header("Content-Transfer-Encoding: binary"); 15 | header('Pragma: public'); 16 | header("Content-length: $size"); 17 | header("Content-type: $type"); 18 | header("Content-Disposition: attachment; filename=$name"); 19 | echo $content; 20 | -------------------------------------------------------------------------------- /php-mysql-download-file/index.php: -------------------------------------------------------------------------------- 1 | query("SELECT * FROM file ORDER BY id DESC"); 7 | 8 | $img_types = array('jpg','png','jpeg','gif'); 9 | ?> 10 | 11 | 12 | 13 | 14 | 15 | PHP Download File From Database 16 | 25 | 26 | 27 | 28 | 29 | num_rows > 0){ ?> 30 | 36 | 37 |

File(s) not found...

38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /php-mysql-download-file/readme.rst: -------------------------------------------------------------------------------- 1 | Please follow the tutorial https://roytuts.com/download-file-from-mysql-blob-using-php/ 2 | -------------------------------------------------------------------------------- /php-mysql-infinite-level-nested-category/category.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS `category` ( 2 | `category_id` int UNSIGNED COLLATE utf8mb4_unicode_ci NOT NULL AUTO_INCREMENT, 3 | `category_name` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, 4 | `category_link` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL, 5 | `parent_id` int UNSIGNED COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0', 6 | `sort_order` int COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0', 7 | PRIMARY KEY (`category_id`), 8 | UNIQUE KEY `unique` (`category_name`) 9 | ) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb4 COLLATE=UTF8MB4_UNICODE_CI; 10 | 11 | INSERT INTO `category` (`category_id`, `category_name`, `category_link`, `parent_id`, `sort_order`) VALUES 12 | (1, 'Home', 'home', 0, 0), 13 | (2, 'Tutorials', 'tutorials', 0, 1), 14 | (3, 'Java', 'java', 2, 1), 15 | (4, 'Liferay', 'liferay', 2, 1), 16 | (5, 'Frameworks', 'frameworks', 0, 2), 17 | (6, 'JSF', 'jsf', 5, 2), 18 | (7, 'Struts', 'struts', 5, 2), 19 | (8, 'Spring', 'spring', 5, 2), 20 | (9, 'Hibernate', 'hibernate', 5, 2), 21 | (10, 'Webservices', 'webservices', 0, 3), 22 | (11, 'REST', 'rest', 10, 3), 23 | (12, 'SOAP', 'soap', 10, 3), 24 | (13, 'Contact', 'contact', 0, 4), 25 | (14, 'About', 'about', 0, 5); 26 | 27 | SELECT 28 | `category_id`, 29 | `category_name`, 30 | `category_link`, 31 | `parent_id`, 32 | `sort_order` 33 | FROM `roytuts`.`category` 34 | ORDER BY parent_id, sort_order, category_name; 35 | -------------------------------------------------------------------------------- /php-mysql-infinite-level-nested-category/php-mysql-infinite-level-nested-category.php: -------------------------------------------------------------------------------- 1 | array(), 14 | 'parent_cats' => array() 15 | ); 16 | 17 | //build the array lists with data from the category table 18 | while ($row = mysqli_fetch_assoc($result)) { 19 | //creates entry into categories array with current category id ie. $categories['categories'][1] 20 | $category['categories'][$row['category_id']] = $row; 21 | //creates entry into parent_cats array. parent_cats array contains a list of all categories with children 22 | $category['parent_cats'][$row['parent_id']][] = $row['category_id']; 23 | } 24 | 25 | function buildCategory($parent, $category) { 26 | $html = ""; 27 | if (isset($category['parent_cats'][$parent])) { 28 | $html .= " \n"; 40 | } 41 | return $html; 42 | } 43 | 44 | 45 | echo buildCategory(0, $category); -------------------------------------------------------------------------------- /php-mysql-infinite-level-nested-category/readme.rst: -------------------------------------------------------------------------------- 1 | Please follow tutorial https://roytuts.com/infinite-dynamic-multi-level-nested-category-with-php-and-mysql/ 2 | -------------------------------------------------------------------------------- /php-mysql-login-logout-remember-me/common.php: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | My Home 14 | 15 | 16 | Welcome! You have successfully logged in. Thank you. 17 | Logout 18 | 19 | -------------------------------------------------------------------------------- /php-mysql-login-logout-remember-me/login.php: -------------------------------------------------------------------------------- 1 | 80) { 17 | $errors .= "\nMax length of Email Address:80"; 18 | $temp.="N"; 19 | } 20 | 21 | if ((!empty($password) && strlen($password) > 20)) { 22 | $errors .= "\nMax length of Password:25"; 23 | $temp.="N"; 24 | } 25 | 26 | if (empty($temp)) { 27 | $_POST['password'] = ''; 28 | $_POST['email'] = ''; 29 | //$clss = 'success'; 30 | $result = user_login($username, $password); 31 | $errors .= $result; 32 | } 33 | } 34 | ?> 35 | 36 | 37 | 38 | 39 | Remember Me Example 40 | 48 | 49 | 50 |
52 | " . nl2br($errors) . "

"; 55 | } 56 | ?> 57 |

Login

58 |
59 | 62 |
63 |
64 | 66 |
67 |

68 | 73 |

74 |
75 | 76 |
77 |
78 | 79 | -------------------------------------------------------------------------------- /php-mysql-login-logout-remember-me/logout.php: -------------------------------------------------------------------------------- 1 | connect_error) { 13 | die("Connection failed: " . $db->connect_error); 14 | } 15 | -------------------------------------------------------------------------------- /php-mysql-view-file/index.php: -------------------------------------------------------------------------------- 1 | query("SELECT * FROM file ORDER BY id DESC"); 7 | 8 | $img_types = array('jpg','png','jpeg','gif'); 9 | ?> 10 | 11 | 12 | 13 | 14 | 15 | PHP Retrieve File From Database 16 | 25 | 26 | 27 | 28 | 29 | num_rows > 0){ ?> 30 | 38 | 39 |

Image(s) not found...

40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /php-nested-comments/add_comment.php: -------------------------------------------------------------------------------- 1 | reply
"; 19 | } else { 20 | $reply_link = ''; 21 | } 22 | $depth = $depth_level + 1; 23 | echo "
  • " . 24 | "{$row['comment_date']}" . 25 | "
    {$row['comment_text']}
    " . 26 | $reply_link . "
  • "; 27 | } 28 | echo '
    Comment successfully posted
    '; 29 | } else { 30 | echo '
    Error in adding comment
    '; 31 | } 32 | } else { 33 | echo '
    Please enter required fields
    '; 34 | } 35 | ?> -------------------------------------------------------------------------------- /php-nested-comments/comments.css: -------------------------------------------------------------------------------- 1 | #comment_wrapper { 2 | width:100%; 3 | font-family:serif,sans-serif,cursive; 4 | } 5 | 6 | #comment_form_wrapper { 7 | margin: 12px 12px 12px 12px; 8 | padding: 12px 0px 12px 12px; /* Note 0px padding right */ 9 | background-color: #ebefee; 10 | border: thin dotted #39C; 11 | } 12 | 13 | #comment_name{ 14 | padding: 4px 2px 4px 5px; 15 | margin: 3px 0 3px 13px; 16 | } 17 | 18 | #comment_email{ 19 | padding: 4px 2px 4px 5px; 20 | margin: 3px 0 3px 15px; 21 | } 22 | 23 | #comment_web{ 24 | padding: 4px 2px 4px 5px; 25 | margin: 3px; 26 | } 27 | 28 | #comment_form textarea { 29 | width: 93.4%; 30 | background: white; 31 | /*border: 4px solid #EEE;*/ 32 | border: 1px solid #eee; 33 | /* -moz-border-radius: 5px; 34 | border-radius: 5px;*/ 35 | padding: 10px; 36 | margin-left: 5px; 37 | font-family:serif,sans-serif,cursive; 38 | font-size:14px; 39 | } 40 | 41 | #comment_resp_err{ 42 | color: red; 43 | font-size: 13px; 44 | } 45 | 46 | ul.comment { 47 | width: 100%; 48 | /* margin: 12px 12px 12px 0px; 49 | padding: 3px 3px 3px 3px;*/ 50 | } 51 | 52 | ul.comment li { 53 | margin: 12px 12px 12px 12px; 54 | padding: 12px 0px 12px 12px; /* Note 0px padding right */ 55 | list-style: none; /* no glyphs before a list item */ 56 | background-color: #ebefee; 57 | border: thin dotted #39C; 58 | } 59 | 60 | ul.comment li span.commenter { 61 | font-weight:bold; 62 | color:#369; 63 | } 64 | 65 | ul.comment li span.comment_date { 66 | color:#666; 67 | } 68 | 69 | #comment_wrapper .button, 70 | #comment_wrapper .reply_button { 71 | background: none repeat scroll 0 0 #5394A8; 72 | color: #FFFFFF; 73 | float: right; 74 | font-size: 10px; 75 | font-weight: bold; 76 | margin: -10px 5px ; 77 | padding: 3px 10px; 78 | text-transform: uppercase; 79 | text-decoration: none; 80 | cursor: pointer; 81 | border: 1px solid #369; 82 | } 83 | 84 | #comment_wrapper #comment_submit { 85 | float:none; 86 | margin: 0px 5px ; 87 | } 88 | 89 | #comment_wrapper .button:hover, 90 | #comment_wrapper .reply_button:hover { 91 | background: none repeat scroll 0 0 #069; 92 | text-decoration: underline; 93 | } 94 | 95 | #cancel-comment-reply-link { 96 | color: #666; 97 | margin-left: 10px; 98 | margin-right:10px; 99 | text-decoration: none; 100 | font-size: 10px; 101 | font-weight: normal; 102 | float:right; 103 | text-transform: uppercase; 104 | } 105 | 106 | #cancel-comment-reply-link:hover{ 107 | text-decoration: underline; 108 | } -------------------------------------------------------------------------------- /php-nested-comments/comments.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /php-nested-comments/comments_blog.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | $("#cancel-comment-reply-link").hide(); 3 | //$(".reply_button").live('click', function(event) { //jQuery upto 1.9 4 | $(".reply_button").on('click', function(event) { //jQuery 1.9+ 5 | event.preventDefault(); 6 | var id = $(this).attr("id"); 7 | //if ($("#li_comment_" + id).find('ul').size() > 0) { //jQuery upto 1.9 8 | if ($("#li_comment_" + id).find('ul').length > 0) { //jQuery 1.9+ 9 | $("#li_comment_" + id + " ul:first").prepend($("#comment_form_wrapper")); 10 | } else { 11 | $("#li_comment_" + id).append($("#comment_form_wrapper")); 12 | } 13 | var depth_level = $('#li_comment_' + id).data('depth-level'); 14 | $("#reply_id").attr("value", id); 15 | $("#depth_level").attr("value", depth_level); 16 | $("#cancel-comment-reply-link").show(); 17 | }); 18 | 19 | $("#cancel-comment-reply-link").bind("click", function(event) { 20 | event.preventDefault(); 21 | $("#reply_id").attr("value", ""); 22 | $("#comment_wrapper").prepend($("#comment_form_wrapper")); 23 | $(this).hide(); 24 | }); 25 | 26 | $("#comment_form").bind("submit", function(event) { 27 | event.preventDefault(); 28 | if ($("#comment_text").val() == "") { 29 | alert("Please enter your comment"); 30 | return false; 31 | } 32 | $.ajax({ 33 | type: "POST", 34 | //async: false, 35 | url: "add_comment.php", 36 | data: $('#comment_form').serialize(), 37 | dataType: "html", 38 | cache: false, 39 | beforeSend: function() { 40 | $('#comment_wrapper').block({ 41 | message: 'Please wait....', 42 | css: { 43 | border: 'none', 44 | padding: '15px', 45 | backgroundColor: '#ccc', 46 | '-webkit-border-radius': '10px', 47 | '-moz-border-radius': '10px' 48 | }, 49 | overlayCSS: { 50 | backgroundColor: '#ffe' 51 | } 52 | }); 53 | }, 54 | success: function(comment) { 55 | var reply_id = $("#reply_id").val(); 56 | if (reply_id == "") { 57 | $("#comment_wrapper ul:first").prepend(comment); 58 | } 59 | else { 60 | //if ($("#li_comment_" + reply_id).find('ul').size() > 0) { //jQuery upto 1.9 61 | if ($("#li_comment_" + reply_id).find('ul').length > 0) { //jQuery 1.9+ 62 | $("#li_comment_" + reply_id + " ul:first").prepend(comment); 63 | } 64 | else { 65 | $("#li_comment_" + reply_id).append('
      ' + comment + '
    '); 66 | } 67 | } 68 | $("#comment_text").attr("value", ""); 69 | $("#reply_id").attr("value", ""); 70 | $("#cancel-comment-reply-link").hide(); 71 | $("#comment_wrapper").prepend($("#comment_form_wrapper")); 72 | $('#comment_wrapper').unblock(); 73 | }, 74 | error: function(jqXHR, textStatus, errorThrown) { 75 | //console.log(textStatus, errorThrown); 76 | alert(textStatus + " " + errorThrown); 77 | } 78 | }); 79 | }); 80 | }); -------------------------------------------------------------------------------- /php-nested-comments/config.php: -------------------------------------------------------------------------------- 1 | $key, 'value' => current($arr)]; 6 | next($arr); 7 | return $result; 8 | } 9 | 10 | function format_comments($comments) { 11 | $html = array(); 12 | $root_id = 0; 13 | foreach ($comments as $comment) 14 | $children[$comment['parent_id']][] = $comment; 15 | 16 | // loop will be false if the root has no children (i.e., an empty comment!) 17 | $loop = !empty($children[$root_id]); 18 | 19 | // initializing $parent as the root 20 | $parent = $root_id; 21 | $parent_stack = array(); 22 | 23 | // HTML wrapper for the menu (open) 24 | $html[] = '
      '; 25 | 26 | //while ($loop && ( ( $option = each($children[$parent]) ) || ( $parent > $root_id ) )) { //below PHP 7.2 27 | while ($loop && ( ( $option = my_each($children[$parent]) ) || ( $parent > $root_id ) )) { //PHP 7.2+ 28 | if ($option === false) { 29 | $parent = array_pop($parent_stack); 30 | 31 | // HTML for comment item containing childrens (close) 32 | $html[] = str_repeat("\t", ( count($parent_stack) + 1 ) * 2) . '
    '; 33 | $html[] = str_repeat("\t", ( count($parent_stack) + 1 ) * 2 - 1) . ''; 34 | } elseif (!empty($children[$option['value']['comment_id']])) { 35 | $tab = str_repeat("\t", ( count($parent_stack) + 1 ) * 2 - 1); 36 | $keep_track_depth = count($parent_stack); 37 | if ($keep_track_depth <= 3) { 38 | $reply_link = '%1$s%1$sreply
    %1$s'; 39 | } else { 40 | $reply_link = ''; 41 | } 42 | //$reply_link = '%1$s%1$sreply
    '; 43 | // HTML for comment item containing childrens (open) 44 | $html[] = sprintf( 45 | '%1$s
  • ' . 46 | '%1$s%1$s
    %4$s
    ' . 47 | '%1$s%1$s
    %3$s
    ' . 48 | $reply_link . '
  • ', $tab, // %1$s = tabulation 49 | $option['value']['comment_id'], //%2$s id 50 | $option['value']['comment_text'], // %3$s = comment 51 | $option['value']['comment_date'] // %4$s = comment created_date 52 | ); 53 | //$check_status = ""; 54 | $html[] = $tab . "\t" . '
      '; 55 | 56 | array_push($parent_stack, $option['value']['parent_id']); 57 | $parent = $option['value']['comment_id']; 58 | } else { 59 | $keep_track_depth = count($parent_stack); 60 | if ($keep_track_depth <= 3) { 61 | $reply_link = '%1$s%1$sreply
      %1$s'; 62 | } else { 63 | $reply_link = ''; 64 | } 65 | 66 | //$reply_link = '%1$s%1$sreply
      %1$s'; 67 | // HTML for comment item with no children (aka "leaf") 68 | $html[] = sprintf( 69 | '%1$s
    • ' . 70 | '%1$s%1$s
      %4$s
      ' . 71 | '%1$s%1$s
      %3$s
      ' . 72 | $reply_link . '
    • ', str_repeat("\t", ( count($parent_stack) + 1 ) * 2 - 1), // %1$s = tabulation 73 | $option['value']['comment_id'], //%2$s id 74 | $option['value']['comment_text'], // %3$s = comment 75 | $option['value']['comment_date'] // %4$s = comment created_date 76 | ); 77 | } 78 | } 79 | 80 | // HTML wrapper for the comment (close) 81 | $html[] = '
    '; 82 | return implode("\r\n", $html); 83 | } 84 | ?> -------------------------------------------------------------------------------- /php-nested-comments/index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Nested or hierarchical comment system in PHP, AJAX, Jquery 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 20 |
    21 |
    22 |
    23 |
    24 |

    Please Leave a ReplyCancel Reply

    25 |
    26 |
    27 | Comment 28 |
    29 |
    30 | 31 | 32 | 33 |
    34 |
    35 |
    36 | 39 |
    40 |
    41 | 42 | -------------------------------------------------------------------------------- /php-nested-comments/readme.rst: -------------------------------------------------------------------------------- 1 | You can read tutorial https://roytuts.com/nested-comment-system-in-php-ajax/ -------------------------------------------------------------------------------- /php-os-detection/php-os-detection.php: -------------------------------------------------------------------------------- 1 | 40 | -------------------------------------------------------------------------------- /php-os-detection/readme.rst: -------------------------------------------------------------------------------- 1 | Please follow the tutorial https://roytuts.com/detect-operating-system-using-php/ 2 | -------------------------------------------------------------------------------- /php-past-future-date/php-past-future-date.php: -------------------------------------------------------------------------------- 1 | "); 27 | echo(strtotime("3 October 2005") . "
    "); 28 | echo(strtotime("+5 hours") . "
    "); 29 | echo(strtotime("+1 week") . "
    "); 30 | echo(strtotime("+1 week 3 days 7 hours 5 seconds") . "
    "); 31 | echo(strtotime("next Monday") . "
    "); 32 | echo(strtotime("last Sunday")); -------------------------------------------------------------------------------- /php-past-future-date/readme.rst: -------------------------------------------------------------------------------- 1 | You can go through the tutorial https://roytuts.com/calculate-future-or-past-date-in-php/ -------------------------------------------------------------------------------- /php-pdo-mysql-rest-api-crud/config/db.php: -------------------------------------------------------------------------------- 1 | conn = null; 14 | 15 | try { 16 | $this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password); 17 | $this->conn->exec("set names utf8"); 18 | } catch (PDOException $exception) { 19 | echo "Database connection error: " . $exception->getMessage(); 20 | } 21 | 22 | return $this->conn; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /php-pdo-mysql-rest-api-crud/department/create.php: -------------------------------------------------------------------------------- 1 | getConnection(); 16 | 17 | // initialize object 18 | $department = new Department($db); 19 | 20 | // get posted data 21 | $data = json_decode(file_get_contents("php://input", true)); 22 | 23 | // set department property value 24 | $department->name = $data->name; 25 | 26 | // create the department 27 | if ($department->create()) { 28 | echo '{'; 29 | echo '"message": "Department was created."'; 30 | echo '}'; 31 | } 32 | 33 | // if unable to create the department, tell the user 34 | else { 35 | echo '{'; 36 | echo '"message": "Unable to create department."'; 37 | echo '}'; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /php-pdo-mysql-rest-api-crud/department/delete.php: -------------------------------------------------------------------------------- 1 | getConnection(); 17 | 18 | // initialize object 19 | $department = new Department($db); 20 | 21 | // set ID property of department to be deleted 22 | $department->id = filter_input(INPUT_GET, 'id'); 23 | 24 | // delete the department 25 | if ($department->delete()) { 26 | echo '{'; 27 | echo '"message": "Department was deleted."'; 28 | echo '}'; 29 | } 30 | 31 | // if unable to delete the department 32 | else { 33 | echo '{'; 34 | echo '"message": "Unable to delete department."'; 35 | echo '}'; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /php-pdo-mysql-rest-api-crud/department/read.php: -------------------------------------------------------------------------------- 1 | getConnection(); 14 | 15 | // initialize object 16 | $department = new Department($db); 17 | 18 | // query department 19 | $stmt = $department->read(); 20 | $num = $stmt->rowCount(); 21 | 22 | // check if more than 0 record found 23 | if ($num > 0) { 24 | // department array 25 | $department_arr = array(); 26 | $department_arr["records"] = array(); 27 | 28 | // retrieve table contents 29 | while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { 30 | // extract row 31 | extract($row); 32 | 33 | $department_item = array( 34 | "id" => $row['dept_id'], 35 | "name" => $row['dept_name'] 36 | ); 37 | 38 | array_push($department_arr["records"], $department_item); 39 | } 40 | 41 | echo json_encode($department_arr); 42 | } else { 43 | echo json_encode( 44 | array("message" => "No record found for department.") 45 | ); 46 | } 47 | 48 | -------------------------------------------------------------------------------- /php-pdo-mysql-rest-api-crud/department/update.php: -------------------------------------------------------------------------------- 1 | getConnection(); 16 | 17 | // initialize object 18 | $department = new Department($db); 19 | 20 | // get posted data 21 | $data = json_decode(file_get_contents("php://input", true)); 22 | 23 | // set ID property of department to be updated 24 | $department->id = $data->id; 25 | // set department property value 26 | $department->name = $data->name; 27 | 28 | // update the department 29 | if ($department->update()) { 30 | echo '{'; 31 | echo '"message": "Department was updated."'; 32 | echo '}'; 33 | } 34 | 35 | // if unable to update the department, tell the user 36 | else { 37 | echo '{'; 38 | echo '"message": "Unable to update department."'; 39 | echo '}'; 40 | } 41 | 42 | -------------------------------------------------------------------------------- /php-pdo-mysql-rest-api-crud/object/department.php: -------------------------------------------------------------------------------- 1 | conn = $db; 21 | } 22 | 23 | // read departments 24 | function read() { 25 | // query to select all 26 | $query = "SELECT d.dept_id, d.dept_name 27 | FROM 28 | " . $this->table_name . " d 29 | ORDER BY 30 | d.dept_id"; 31 | 32 | // prepare query statement 33 | $stmt = $this->conn->prepare($query); 34 | 35 | // execute query 36 | $stmt->execute(); 37 | 38 | return $stmt; 39 | } 40 | 41 | // create department 42 | function create() { 43 | // query to insert record 44 | $query = "INSERT INTO 45 | " . $this->table_name . " 46 | SET 47 | dept_name=:name"; 48 | 49 | // prepare query 50 | $stmt = $this->conn->prepare($query); 51 | 52 | // sanitize 53 | $this->name = htmlspecialchars(strip_tags($this->name)); 54 | 55 | // bind values 56 | $stmt->bindParam(":name", $this->name); 57 | 58 | // execute query 59 | if ($stmt->execute()) { 60 | return true; 61 | } else { 62 | return false; 63 | } 64 | } 65 | 66 | // update the department 67 | function update() { 68 | // update query 69 | $query = "UPDATE 70 | " . $this->table_name . " 71 | SET 72 | dept_name = :name 73 | WHERE 74 | dept_id = :id"; 75 | 76 | // prepare query statement 77 | $stmt = $this->conn->prepare($query); 78 | 79 | // sanitize 80 | $this->name = htmlspecialchars(strip_tags($this->name)); 81 | $this->id = htmlspecialchars(strip_tags($this->id)); 82 | 83 | // bind new values 84 | $stmt->bindParam(':name', $this->name); 85 | $stmt->bindParam(':id', $this->id); 86 | 87 | // execute the query 88 | if ($stmt->execute()) { 89 | return true; 90 | } else { 91 | return false; 92 | } 93 | } 94 | 95 | // delete the department 96 | function delete() { 97 | // delete query 98 | $query = "DELETE FROM " . $this->table_name . " WHERE dept_id = ?"; 99 | 100 | // prepare query 101 | $stmt = $this->conn->prepare($query); 102 | 103 | // sanitize 104 | $this->id = htmlspecialchars(strip_tags($this->id)); 105 | 106 | // bind id of record to delete 107 | $stmt->bindParam(1, $this->id); 108 | 109 | // execute query 110 | if ($stmt->execute()) { 111 | return true; 112 | } 113 | 114 | return false; 115 | } 116 | } 117 | 118 | -------------------------------------------------------------------------------- /php-pdo-mysql-rest-api-crud/readme.rst: -------------------------------------------------------------------------------- 1 | Please follow the tutorial https://roytuts.com/rest-api-crud-example-in-php-mysql/ 2 | -------------------------------------------------------------------------------- /php-pdo-mysql-rest-api-crud/rest-client/crud-operations.php: -------------------------------------------------------------------------------- 1 | "FINNCIAL")); 35 | 36 | $response = perform_http_request('POST', $rest_api_base_url . $post_endpoint, $request_data); 37 | 38 | echo $response . "\n"; 39 | 40 | //fetch all departments 41 | $response = perform_http_request('GET', $rest_api_base_url . $get_endpoint); 42 | 43 | echo 'List Of Departments:' . "\n"; 44 | echo $response . "\n"; 45 | 46 | echo "\n" . 'UPDATE' . "\n"; 47 | echo '---------------------' . "\n"; 48 | 49 | //PUT - update department 50 | $put_endpoint = '/department/update.php'; 51 | 52 | $request_data = json_encode(array("id" => 41, "name" => "FINANCIAL")); 53 | 54 | $response = perform_http_request('PUT', $rest_api_base_url . $put_endpoint, $request_data); 55 | 56 | echo $response . "\n"; 57 | 58 | //fetch all departments 59 | $response = perform_http_request('GET', $rest_api_base_url . $get_endpoint); 60 | 61 | echo 'List Of Departments:' . "\n"; 62 | echo $response . "\n"; 63 | 64 | echo "\n" . 'DELETE' . "\n"; 65 | echo '---------------------' . "\n"; 66 | 67 | //DELETE - delete department 68 | $delete_endpoint = '/department/delete.php?id=41'; 69 | 70 | $response = perform_http_request('DELETE', $rest_api_base_url . $delete_endpoint); 71 | 72 | echo $response . "\n"; 73 | 74 | //fetch all departments 75 | $response = perform_http_request('GET', $rest_api_base_url . $get_endpoint); 76 | 77 | echo 'List Of Departments:' . "\n"; 78 | echo $response . "\n"; 79 | 80 | 81 | -------------------------------------------------------------------------------- /php-pdo-mysql-rest-api-crud/rest-client/rest-client.php: -------------------------------------------------------------------------------- 1 | curl_error($curl), "code" => curl_errno($curl))))); 37 | } 38 | 39 | curl_close($curl); 40 | 41 | return $result; 42 | } 43 | 44 | -------------------------------------------------------------------------------- /php-pretty-print-json/input.json: -------------------------------------------------------------------------------- 1 | {"one":"AAA","two":["BBB","CCC"],"three":{"four":"DDD","five":["EEE","FFF"]}} 2 | -------------------------------------------------------------------------------- /php-pretty-print-json/output.json: -------------------------------------------------------------------------------- 1 | { 2 | "one": "AAA", 3 | "two": [ 4 | "BBB", 5 | "CCC" 6 | ], 7 | "three": { 8 | "four": "DDD", 9 | "five": [ 10 | "EEE", 11 | "FFF" 12 | ] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /php-pretty-print-json/php-pretty-print-json.php: -------------------------------------------------------------------------------- 1 | 'AAA', 'two' => array('BBB', 'CCC'), 'three' => array('four' => 'DDD', 'five' => array('EEE', 'FFF'))); 5 | 6 | //echo json_encode($json, 128); 7 | 8 | echo json_encode($json, JSON_PRETTY_PRINT); 9 | 10 | //echo json_encode($json, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); 11 | 12 | 13 | /** 14 | * Pretty Print From A File 15 | **/ 16 | 17 | $filename = "input.json"; 18 | $file = fopen( $filename, "r" ); 19 | 20 | if( $file == false ) { 21 | echo ( "Error in opening file" ); 22 | exit(); 23 | } 24 | 25 | $filesize = filesize( $filename ); 26 | $filecontent = fread( $file, $filesize ); 27 | fclose( $file ); 28 | 29 | $filename = "output.json"; 30 | $file = fopen( $filename, "w" ); 31 | 32 | if( $file == false ) { 33 | echo ( "Error in opening new file" ); 34 | exit(); 35 | } 36 | 37 | fwrite($file, json_encode(json_decode($filecontent), JSON_PRETTY_PRINT)); 38 | fclose( $file ); 39 | -------------------------------------------------------------------------------- /php-pretty-print-json/readme.rst: -------------------------------------------------------------------------------- 1 | Please follow the tutorial https://roytuts.com/pretty-print-json-in-php/ 2 | -------------------------------------------------------------------------------- /php-read-write-csv-file/php-read-write-csv-file.php: -------------------------------------------------------------------------------- 1 | '; 7 | echo 'NameEmailDate Of Birth'; 8 | echo ''; 9 | while (($data = fgetcsv($handle, 0, ",")) !== FALSE) { 10 | echo '' . $data[0] . '' . $data[1] . '' . $data[2] . ''; 11 | $infos[] = $data[0] . ',' . $data[1] . ',' . $data[2]; 12 | } 13 | echo ''; 14 | fclose($handle); 15 | } 16 | 17 | $fp = fopen('write.csv', 'w'); 18 | 19 | foreach ($infos as $info) { 20 | fputcsv($fp, array($info), ',', ' '); 21 | } 22 | 23 | fclose($fp); 24 | /* 25 | * End of php-read-write-csv-file.php 26 | */ 27 | 28 | -------------------------------------------------------------------------------- /php-read-write-csv-file/read.csv: -------------------------------------------------------------------------------- 1 | abc xyz,bdhur@mail.com,20/05/1874 2 | abe xuz,sumaut@mail.com,05/04/1987 3 | dfa jyz,akash@hr.com,04/07/1864 4 | fff hgh,arya.p@tech.com,05/05/1905 -------------------------------------------------------------------------------- /php-read-write-csv-file/readme.rst: -------------------------------------------------------------------------------- 1 | Please follow the tutorial https://roytuts.com/read-from-and-write-to-a-csv-file-using-php/ 2 | -------------------------------------------------------------------------------- /php-read-write-csv-file/write.csv: -------------------------------------------------------------------------------- 1 | abc xyz,bdhur@mail.com,20/05/1874 2 | abe xuz,sumaut@mail.com,05/04/1987 3 | dfa jyz,akash@hr.com,04/07/1864 4 | fff hgh,arya.p@tech.com,05/05/1905 5 | -------------------------------------------------------------------------------- /php-rest-api-multiple-files-upload/client/php-files-upload-rest-client.php: -------------------------------------------------------------------------------- 1 | 4 | curl_file_create('C:\Cognizant\MyDocs\java-math-round-issue.docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'Word-doc.docx'), 5 | 'sendfile[1]' => curl_file_create('C:\Cognizant\MyDocs\myphoto.jpg', 'image/jpeg', 'mine.jpg'));*/ 6 | 7 | /*$data = array('sendfile[0]' => 8 | new cURLFile('C:\Cognizant\MyDocs\java-math-round-issue.docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'Word-doc.docx'), 9 | 'sendfile[1]' => new cURLFile('C:\Cognizant\MyDocs\myphoto.jpg', 'image/jpeg', 'mine.jpg'));*/ 10 | 11 | $data = array(); 12 | $data['sendfile[0]'] = curl_file_create('C:\Cognizant\MyDocs\java-math-round-issue.docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'Word-doc.docx'); 13 | $data['sendfile[1]'] = curl_file_create('C:\Cognizant\MyDocs\myphoto.jpg', 'image/jpeg', 'mine.jpg'); 14 | 15 | $ch = curl_init(); 16 | curl_setopt($ch, CURLOPT_URL, 'http://localhost/php-rest-api-files-upload.php'); 17 | curl_setopt($ch, CURLOPT_HTTPHEADER,array('Content-Type: multipart/form-data')); 18 | curl_setopt($ch, CURLOPT_POST, 1); 19 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 20 | $response = curl_exec($ch); 21 | curl_close($ch); 22 | -------------------------------------------------------------------------------- /php-rest-api-multiple-files-upload/readme.rst: -------------------------------------------------------------------------------- 1 | Please follow the tutorial https://roytuts.com/php-rest-api-multiple-files-upload/ 2 | -------------------------------------------------------------------------------- /php-rest-api-multiple-files-upload/server/php-rest-api-files-upload.php: -------------------------------------------------------------------------------- 1 | "please select a file")); 12 | } else { 13 | $upload_path = 'upload/'; // set upload folder path 14 | 15 | // valid file extensions 16 | $valid_extensions = array('jpeg', 'jpg', 'png', 'gif', 'pdf', 'docx', 'txt'); 17 | 18 | $total = count($_FILES['sendfile']['name']); 19 | 20 | $msg = array(); 21 | 22 | for( $i=0 ; $i < $total ; $i++ ) { 23 | $fileName = $_FILES['sendfile']['name'][$i]; 24 | $tempPath = $_FILES['sendfile']['tmp_name'][$i]; 25 | $fileSize = $_FILES['sendfile']['size'][$i]; 26 | 27 | $fileExt = strtolower(pathinfo($fileName, PATHINFO_EXTENSION)); // get file extension 28 | 29 | // allow valid file formats 30 | if(in_array($fileExt, $valid_extensions)) { 31 | //check file does not exist in the upload folder path 32 | if(!file_exists($upload_path . $fileName)) { 33 | // check file size '5MB' 34 | if($fileSize < 5000000) { 35 | if(move_uploaded_file($tempPath, $upload_path . $fileName)) { // move file from system temporary path to the upload folder path 36 | $msg[$i] = "File Uploaded Successfully: " . $fileName; 37 | } else { 38 | $msg[$i] = "File couldn't be uploaded: " . $fileName; 39 | } 40 | } else { 41 | $msg[$i] = "Sorry, your file is too large, please upload up to 5 MB in size: " . $fileName; 42 | } 43 | } else { 44 | $msg[$i] = "Sorry, file already exists check upload folder: " . $fileName; 45 | } 46 | } else { 47 | $msg[$i] = "Sorry, only JPG, JPEG, PNG, GIF, PDF, DOCX & TEXT files are allowed: " . $fileName; 48 | } 49 | } 50 | 51 | echo json_encode($msg); 52 | } 53 | 54 | -------------------------------------------------------------------------------- /php-rest-api-single-file-upload/client/php-file-upload-rest-client.php: -------------------------------------------------------------------------------- 1 | curl_file_create('C:\MyDocs\java-math-round-issue.docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'Word-doc.docx')); 4 | 5 | $ch = curl_init(); 6 | curl_setopt($ch, CURLOPT_URL, 'http://localhost/php-rest-api-file-upload.php'); 7 | curl_setopt($ch, CURLOPT_HTTPHEADER,array('Content-Type: multipart/form-data')); 8 | curl_setopt($ch, CURLOPT_POST, 1); 9 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 10 | $response = curl_exec($ch); 11 | curl_close($ch); 12 | -------------------------------------------------------------------------------- /php-rest-api-single-file-upload/readme.rst: -------------------------------------------------------------------------------- 1 | Please follow the tutorial https://roytuts.com/php-rest-api-single-file-upload/ 2 | -------------------------------------------------------------------------------- /php-rest-api-single-file-upload/server/php-rest-api-file-upload.php: -------------------------------------------------------------------------------- 1 | "please select a file", "status" => false)); 16 | } else { 17 | $upload_path = 'upload/'; // set upload folder path 18 | 19 | $fileExt = strtolower(pathinfo($fileName, PATHINFO_EXTENSION)); // get file extension 20 | 21 | // valid file extensions 22 | $valid_extensions = array('jpeg', 'jpg', 'png', 'gif', 'pdf', 'docx', 'txt'); 23 | 24 | // allow valid file formats 25 | if(in_array($fileExt, $valid_extensions)) { 26 | //check file does not exist in the upload folder path 27 | if(!file_exists($upload_path . $fileName)) { 28 | // check file size '5MB' 29 | if($fileSize < 5000000) { 30 | if(move_uploaded_file($tempPath, $upload_path . $fileName)) { // move file from system temporary path to the upload folder path 31 | echo json_encode(array("message" => "File Uploaded Successfully", "status" => true)); 32 | } else { 33 | echo json_encode(array("message" => "File couldn't be uploaded", "status" => false)); 34 | } 35 | } else { 36 | echo json_encode(array("message" => "Sorry, your file is too large, please upload 5 MB size", "status" => false)); 37 | } 38 | } else { 39 | echo json_encode(array("message" => "Sorry, file already exists check upload folder", "status" => false)); 40 | } 41 | } else { 42 | echo json_encode(array("message" => "Sorry, only JPG, JPEG, PNG, GIF, PDF, DOCX & TEXT files are allowed", "status" => false)); 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /php-save-file-mysql/db_config.php: -------------------------------------------------------------------------------- 1 | connect_error) { 13 | die("Connection failed: " . $db->connect_error); 14 | } 15 | -------------------------------------------------------------------------------- /php-save-file-mysql/file.sql: -------------------------------------------------------------------------------- 1 | 2 | CREATE DATABASE IF NOT EXISTS `roytuts`; 3 | USE `roytuts`; 4 | 5 | CREATE TABLE IF NOT EXISTS `file` ( 6 | `id` int unsigned NOT NULL AUTO_INCREMENT, 7 | `name` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 8 | `content` mediumblob, 9 | `size` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 10 | `type` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 11 | `created` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL, 12 | PRIMARY KEY (`id`) 13 | ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; 14 | -------------------------------------------------------------------------------- /php-save-file-mysql/index.php: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 12 | PHP Save File To Database 13 | 14 | 15 | 16 | query("INSERT into file (name, content, size, type, created) VALUES ('$file_name', '$imgContent', '$file_size', '$fileType', NOW())"); 35 | 36 | if($insert){ 37 | $status = 'success'; 38 | $status_msg = 'File uploaded successfully.'; 39 | }else{ 40 | $status_msg = 'File upload failed, please try again.'; 41 | } 42 | }else{ 43 | $status_msg = 'Please select a file to upload.'; 44 | } 45 | } 46 | 47 | // Display status message 48 | echo $status_msg; 49 | ?> 50 | 51 |

    52 | 53 |

    54 | 55 | 56 | 57 |
    58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /php-save-file-mysql/utils.php: -------------------------------------------------------------------------------- 1 | array( 14 | "UNIT" => "TB", 15 | "VALUE" => pow(1024, 4) 16 | ), 17 | 1 => array( 18 | "UNIT" => "GB", 19 | "VALUE" => pow(1024, 3) 20 | ), 21 | 2 => array( 22 | "UNIT" => "MB", 23 | "VALUE" => pow(1024, 2) 24 | ), 25 | 3 => array( 26 | "UNIT" => "KB", 27 | "VALUE" => 1024 28 | ), 29 | 4 => array( 30 | "UNIT" => "B", 31 | "VALUE" => 1 32 | ), 33 | ); 34 | 35 | foreach($arBytes as $arItem) 36 | { 37 | if($bytes >= $arItem["VALUE"]) 38 | { 39 | $result = $bytes / $arItem["VALUE"]; 40 | $result = strval(round($result, 2)) . " " . $arItem["UNIT"]; 41 | break; 42 | } 43 | } 44 | return $result; 45 | } 46 | 47 | ?> 48 | -------------------------------------------------------------------------------- /php-session-expiry-message/home.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | My Home 9 | 10 | 24 | 25 | 49 | 50 | 51 | $_SESSION['expiry_time']) { 58 | $_SESSION = array(); 59 | session_destroy(); 60 | echo "Your session has expired! Login here"; 61 | } else { 62 | ?> 63 | Welcome . You have successfully logged in. 64 | Logout 65 | 69 |
    70 |

    71 | Your session has expired!

    Please Click Here 72 | to go back to Login Page.
    73 |
    74 |
    You will be automatically redirected after 5 seconds... 75 |

    76 |
    77 | 78 | -------------------------------------------------------------------------------- /php-session-expiry-message/login.php: -------------------------------------------------------------------------------- 1 | 26 | 27 | 28 | 29 | 30 | PHP Login 31 | 39 | 40 | 41 |
    42 | " . nl2br($errors) . "

    "; 45 | } 46 | ?> 47 |

    Login

    48 |
    49 | 52 |
    53 |
    54 | 55 |
    56 |
    57 | 58 |
    59 |
    60 | 61 | -------------------------------------------------------------------------------- /php-session-expiry-message/logout.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PHP Single File Upload Example 6 | 7 | 8 |

    Single File Upload Example using PHP

    9 | Error during file upload ' . $_FILES['file']['error'] . ''; 14 | } else { 15 | if (file_exists('uploads/' . $_FILES['file']['name'])) { 16 | echo 'File already exists at uploads/' . $_FILES['file']['name'] . ''; 17 | } else { 18 | move_uploaded_file($_FILES['file']['tmp_name'], 'uploads/' . $_FILES['file']['name']); 19 | echo 'File successfully uploaded to uploads/' . $_FILES['file']['name'] . ''; 20 | } 21 | } 22 | } else { 23 | echo 'Please choose a file'; 24 | } 25 | echo nl2br("\n"); 26 | } 27 | ?> 28 | 29 |
    30 |  

    31 | 32 |
    33 | 34 | -------------------------------------------------------------------------------- /php-single-file-upload/readme.rst: -------------------------------------------------------------------------------- 1 | Please follow the tutorial https://roytuts.com/php-file-upload-example/ 2 | -------------------------------------------------------------------------------- /php-sri-hash-generator/php-sri-hash-generator.php: -------------------------------------------------------------------------------- 1 | 30 | -------------------------------------------------------------------------------- /php-sri-hash-generator/readme.rst: -------------------------------------------------------------------------------- 1 | Please follow the tutorial https://roytuts.com/html-script-integrity-attribute-subrresource-integrity-sri/ -------------------------------------------------------------------------------- /php-sri-hash-generator/sample.js: -------------------------------------------------------------------------------- 1 | // program to check a number is prime or not 2 | 3 | // get input from the user 4 | const number = parseInt(prompt("Enter a positive number: ")); 5 | let isPrime = true; 6 | 7 | // check if number is equal to 1 8 | if (number === 1) { 9 | console.log("1 is neither prime nor composite number."); 10 | } 11 | 12 | // check if number is greater than 1 13 | else if (number > 1) { 14 | 15 | // looping through 2 to number-1 16 | for (let i = 2; i < number; i++) { 17 | if (number % i == 0) { 18 | isPrime = false; 19 | break; 20 | } 21 | } 22 | 23 | if (isPrime) { 24 | console.log(`${number} is a prime number`); 25 | } else { 26 | console.log(`${number} is a not prime number`); 27 | } 28 | } 29 | 30 | // check if number is less than 1 31 | else { 32 | console.log("The number is not a prime number."); 33 | } -------------------------------------------------------------------------------- /php-time-ago-or-time-to-go/readme.rst: -------------------------------------------------------------------------------- 1 | Please follow the tutorial https://roytuts.com/time-ago-or-time-to-go-function-in-php/ 2 | -------------------------------------------------------------------------------- /php-time-ago-or-time-to-go/time-ago-or-time-to-go.php: -------------------------------------------------------------------------------- 1 | '.date('Y-m-d H:i:s')."\n"); 4 | 5 | $date = '2014-04-10 14:20:15'; 6 | echo nl2br($date. ' -> ' . time_ago($date)."\n"); 7 | 8 | $date = '2016-07-20 14:20:15'; 9 | echo nl2br($date. ' -> ' . time_ago($date)."\n"); 10 | 11 | $date = '2019-08-13 05:43:45'; 12 | echo nl2br($date. ' -> ' . time_ago($date)."\n"); 13 | 14 | 15 | function time_ago($date) { 16 | $is_valid = is_date_time_valid($date); 17 | 18 | if ($is_valid) { 19 | $timestamp = strtotime($date); 20 | $difference = time() - $timestamp; 21 | $periods = array("sec", "min", "hour", "day", "week", "month", "year", "decade"); 22 | $lengths = array("60", "60", "24", "7", "4.35", "12", "10"); 23 | 24 | if ($difference > 0) { // this was in the past time 25 | $ending = "ago"; 26 | } else { // this is in the future time 27 | $difference = -$difference; 28 | $ending = "to go"; 29 | } 30 | 31 | for ($j = 0; $difference >= $lengths[$j]; $j++) 32 | $difference /= $lengths[$j]; 33 | 34 | $difference = round($difference); 35 | 36 | if ($difference > 1) 37 | $periods[$j].= "s"; 38 | 39 | $text = "$difference $periods[$j] $ending"; 40 | 41 | return $text; 42 | } else { 43 | return 'Date Time must be in "yyyy-mm-dd hh:mm:ss" format'; 44 | } 45 | } 46 | 47 | function is_date_time_valid($date) { 48 | 49 | if (date('Y-m-d H:i:s', strtotime($date)) == $date) { 50 | return TRUE; 51 | } else { 52 | return FALSE; 53 | } 54 | } --------------------------------------------------------------------------------