Simcy Creative
  • What is Simcify
  • Requirements
  • Getting Started
  • Javascript Functions
    • Simple js Functions
    • Interaction Functions
      • Loader
      • Notifications
      • Credit Card Form
    • Helper Functions
      • Random
      • Cookies
      • Send to server(Ajax)
      • Server Responses
    • HTML helpers
      • Form Processing
      • Send onClick
      • Send onChange
      • Fetch & Display
      • Dropify
      • Switchery
      • Crop Image Input
      • Image Preview
  • PHP Functions
    • Introduction
    • Setup
    • Authentication
      • Login
      • Register
      • Forgot Password
      • Reset Password
    • Configuration
    • Email & SMS
      • SMS
        • Africa's Talking
        • Twilio
      • Email
    • Files Manager
      • Upload
      • Delete
Powered by GitBook
On this page
  • Parameters
  • $options explanation
  • Usage
  • Response
  1. PHP Functions
  2. Files Manager

Upload

This is one function that uploads and validates files, crop/resize images among other features.

Parameters

Parameter

Required

Type

Description

$file

Yes

string

This could be a url path to a file, base64 image or $_FILES from a form.

$storage

No

string

The folder inside /uploads to save the uploaded file. default is general

$options

No

array

Explained on the table below.

$options explanation

Key

Type

Description

source

string

Define the source of your file ( form | base64 | url ) Default if form.

extension

string

The extension(png, pdf, .....) of your output, this is required if your source is url.

allowedExtensions

string

Allowed extension separated by a comma, the upload will fail if extension don't match.

resize

array

Pass this array if you are uploading an image you want to crop. Sample array on usage section below

crop

array

Pass this array you are uploading an image to resize. Sample array of the usage section below

Usage

use Simcify\File;

File::upload(
    "https://example.com/image.png", 
    "books",
    array(
        "source" => "url",
        "extension" => "png"
        "allowedExtesions" => "png, jpg, gif",
        "crop" => array(
                    "width" => "300",
                    "height" => "300"
                  ),
        "resize" => array(
                    "maxWidth" => "300",
                    "maxHeight" => "300"
                  )
    )
)

Response

array(
    "status" => "success",
    "title" => "File Uploaded",
    "message" => "File successfully uploaded.",
    "info" => array(
        "name" => $fileName,
        "path" => $outputFile,
        "extension" => $options['extension'],
        "size" => $fileSize,
        )
)
PreviousFiles ManagerNextDelete

Last updated 6 years ago