PHP Classes

File: example2.php

Recommend this page to a friend!
  Classes of alismith   PHP Files Class   example2.php   Download  
File: example2.php
Role: Example script
Content type: text/plain
Description: example usages
Class: PHP Files Class
Manage uploaded files and serve them for download
Author: By
Last change:
Date: 4 years ago
Size: 1,248 bytes
 

Contents

Class file image Download
Example 1 : Multi Files Upload

HTML :
<form action="" method="post" enctype="multipart/form-data">
    Select image to upload:
    <input type="file" name="file" id="file" multiple>
    <input type="submit" value="Upload Image" name="submit">
</form>

PHP :
$validation = ["file"=>"mime=png,jpg,gif|multiple=true"];
$file = new \Utilities\File\Files('file',$validation);
$result = $file->store('/');

echo '<pre>';
print_r($result);


Example 2 : Parallel Files send
HTML :
<form action="" method="post" enctype="multipart/form-data">
    Select image for Profile:
    <input type="file" name="file1" id="file1"><br/>
    Select image for Background:
    <input type="file" name="file2" id="file2"><br/>
    <input type="submit" value="Upload Images" name="submit">
</form>

PHP :
$validation = [
         "file1"=>"mime=png,jpg,gif",
         "file2"=>"mime=png,jpg,gif"
];
$store_path = [
         "file1"=>"images/profile",
         "file2"=>"images/background"
];

$store_name = [
         "file1"=>"myProfile",
         "file2"=>"myBackground"
];
$file = new \Utilities\File\Files(['file1','file2'],$validation);
$result = $file->store($store_path,$store_name);

echo '<pre>';
print_r($result);