Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $uni_id = 123456789;
- if(isset($_FILES['img'])){
- $img = $_FILES['img'];
- print_r($img);
- echo "<br />";
- // File Properties
- $img_name = $img['name'];
- $img_tmp = $img['tmp_name'];
- $img_size = $img['size'];
- $img_error = $img['error'];
- // Work Out The File extension
- $img_ext = explode('.', $img_name); // Java = split to array
- $img_ext = strtolower(end($img_ext)); // last index the array ( file_ext )
- $allowed_img = array('jpg','jpeg','png');
- if (in_array($img_ext, $allowed_img)) {
- if ($img_error === 0) {
- if ($img_size <= 4194000) { // max 4 MB
- echo "3";
- $img_name_new = $uni_id.'.'.$img_ext; // change this to book name ( Random )
- $path_img = "../books/".$uni_id.'/'; // Create a folder if it doesn't already exist (need work)
- if (!file_exists($path_img)) { mkdir($path_img, 0777, true); echo "4";
- }
- $img_destination = $path_img.$img_name_new;
- if (move_uploaded_file($img_tmp, $img_destination)) {
- echo "5";
- }
- }
- }
- }
- }
- ?>
- <?php
- if(isset($_FILES['file'])){
- $file = $_FILES['file'];
- print_r($file);
- echo "<br />";
- // File Properties
- $file_name = $file['name'];
- $file_tmp = $file['tmp_name'];
- $file_size = $file['size'];
- $file_error = $file['error'];
- // Work Out The File extension
- $file_ext = explode('.', $file_name); // Java = split to array
- $file_ext = strtolower(end($file_ext)); // last index the array ( file_ext )
- $allowed = array('rar','zip','7z');
- if (in_array($file_ext, $allowed)) {
- if ($file_error === 0) {
- if ($file_name <= 268400000 ) { // max 100 MB
- $file_name_new = $uni_id.'.'.$file_ext; // change this to book name ( Random )
- $path = "../books/".$uni_id.'/'; // Create a folder if it doesn't already exist
- if (!file_exists($path)) { mkdir($path, 0777, true); }
- $file_destination = $path.$file_name_new;
- if (move_uploaded_file($file_tmp, $file_destination)) {
- }
- }
- }
- }
- }
- ?>
- <?php
- if(isset($_FILES['up_book'])){
- $up_book = $_FILES['up_book'];
- print_r($up_book);
- echo "<br />";
- // up_book Properties
- $up_book_name = $up_book['name'];
- $up_book_tmp = $up_book['tmp_name'];
- $up_book_size = $up_book['size'];
- $up_book_error = $up_book['error'];
- // Work Out The up_book extension
- $up_book_ext = explode('.', $up_book_name); // Java = split to array
- $up_book_ext = strtolower(end($up_book_ext)); // last index the array ( up_book_ext )
- $allowed_BOOK = array('pdf','doc','docx','epub','ppt','pptx');
- if (in_array($up_book_ext, $allowed_BOOK)) {
- if ($up_book_error === 0) {
- if ($up_book_name <= 104900000) { // max 100 MB
- $up_book_name_new = strtolower($up_book_name).'.'.$up_book_ext; // change this to book name
- $path_up_book = "../books/".$uni_id.'/'; // Create a folder if it doesn't already exist
- if (!file_exists($path_up_book)) { mkdir($path_up_book, 0777, true); }
- $up_book_destination = $path_up_book.$up_book_name_new;
- if (move_uploaded_file($up_book_tmp, $up_book_destination)) {
- }
- }
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement