PHP Classes

File: WIAdmin/WICore/WIClass/upload.php

Recommend this page to a friend!
  Classes of Jules Warner   WICMS   WIAdmin/WICore/WIClass/upload.php   Download  
File: WIAdmin/WICore/WIClass/upload.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: WICMS
Database driven content management system with PDO
Author: By
Last change: WI CMS

I am in process of building up my own cms system, its not quiet complete
yet.
There are multiple PDO classes, database driven, in process of making an
installer package for it.
The back end is being built UI with drag and drop, for a simple set up
Date: 7 years ago
Size: 855 bytes
 

Contents

Class file image Download
<?php
/**
 * This is just an example of how a file could be processed from the
 * upload script. It should be tailored to your own requirements.
 */

// Only accept files with these extensions
$whitelist = array('jpg', 'jpeg', 'png', 'gif');
$name = null;
$error = 'No file uploaded.';


if (isset(
$_FILES)) {
    if (isset(
$_FILES['file'])) {
       
$tmp_name = $_FILES['file']['tmp_name'];
       
$name = "../../WIMedia/Img/header/" . basename($_FILES['file']['name']);
       
$error = $_FILES['file']['error'];
       
       
        if (
$error === UPLOAD_ERR_OK) {
           
$extension = pathinfo($name, PATHINFO_EXTENSION);

            if (!
in_array($extension, $whitelist)) {
               
$error = 'Invalid file type uploaded.';
            } else {
               
move_uploaded_file($tmp_name, $name);
               
//echo $name;
           
}
        }
    }
}

echo
json_encode(array(
   
'name' => $name,
   
'error' => $error,
));
die();