PHP Classes

File: uploads/uploadify/uploadify.php

Recommend this page to a friend!
  Classes of Minh Tien   Noblesse CMS   uploads/uploadify/uploadify.php   Download  
File: uploads/uploadify/uploadify.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Noblesse CMS
Content management system with custom plugins
Author: By
Last change:
Date: 9 years ago
Size: 834 bytes
 

Contents

Class file image Download
<?php
/*
Uploadify
Copyright (c) 2012 Reactive Apps, Ronnie Garcia
Released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/

// Define a destination
$targetFolder = '/uploads'; // Relative to the root

$verifyToken = md5('unique_salt' . $_POST['timestamp']);

if (!empty(
$_FILES) && $_POST['token'] == $verifyToken) {
   
$tempFile = $_FILES['Filedata']['tmp_name'];
   
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
   
$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
   
   
// Validate the file type
   
$fileTypes = array('jpg','jpeg','gif','png'); // File extensions
   
$fileParts = pathinfo($_FILES['Filedata']['name']);
   
    if (
in_array($fileParts['extension'],$fileTypes)) {
       
move_uploaded_file($tempFile,$targetFile);
        echo
'1';
    } else {
        echo
'Invalid file type.';
    }
}
?>