PHP Classes

File: uploady/logic/downloadLogic.php

Recommend this page to a friend!
  Classes of Faris AL-Otabi   Uploady PHP Upload File to MySQL   uploady/logic/downloadLogic.php   Download  
File: uploady/logic/downloadLogic.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Uploady PHP Upload File to MySQL
Store file upload details in a MySQL database
Author: By
Last change: Update of uploady/logic/downloadLogic.php
Date: 1 month ago
Size: 1,206 bytes
 

Contents

Class file image Download
<?php

$handler
= new Uploady\Handler\UploadHandler($db);

if (isset(
$_GET['file_id'])) {
    if (!
$handler->fileExist($_GET['file_id'])) {
        die(
$lang["general"]['file_not_found']);
    }

   
$file = $handler->getFile($_GET['file_id']);
   
$file_data = json_decode($file->file_data);
   
$file_settings = json_decode($file->file_settings, true);


    if (
$file_settings['delete_at']["downloads"] != 0) {
        if (
$file_settings['delete_at']["downloads"] <= $file->downloads) {
           
$handler->deleteFileAsAdmin($_GET['file_id']);
           
unlink(realpath("uploads/{$_GET['user_id']}/{$file->filename}"));
           
$utils->redirect(SITE_URL);
        }
    }

    if (
$file_settings['delete_at']["days"] != 0) {
        if (
           
$file_settings['delete_at']["days"] <=
           
round((time() - strtotime($file->uploaded_at)) / (60 * 60 * 24))
        ) {
           
$handler->deleteFileAsAdmin($_GET['file_id']);
           
unlink(realpath("uploads/{$_GET['user_id']}/{$file->filename}"));
           
$utils->redirect(SITE_URL);
        }
    }

   
$handler->addDownload($_GET['file_id']);
}

$page = 'download_file';
$title = $lang["general"]['download_file_title'];