2017 © Pedro Peláez
 

library mymodule

Class to handle uploading of images within the Anax-MVC framework

image

tommy001/mymodule

Class to handle uploading of images within the Anax-MVC framework

  • Monday, March 2, 2015
  • by Tommy001
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

mymodule

Scrutinizer Code Quality Code Coverage Build Status, (*1)

mymodule is a class for handling image uploads in the Anax-MVC framework (see https://github.com/mosbth/Anax-MVC), (*2)

License

This software is free software and carries a MIT license., (*3)

Description and test guide

mymodule contains the php class UploadController that you can use to process uploaded images within the Anax-MVC framework. Future versions will also allow downloads from secure folders on or above root level using a simple proxy script. In this first version there is no support for downloads and uploaded files are stored in the default folder Anax-MVC/webroot/img (where you will need to create a new writable folder named "upload")., (*4)

The uploaded file is passed through a try and catch method where it is checked for errors, invalid parameters, file size defined in the upload form (MAX_FILE_SIZE) and also defined in the script itself. The filename length is limited to 100 characters and only JPG, PNG and GIF images are allowed. If the file pass the "valid upload file" check performed by "move_uploaded_file()" it is stored on disk with a secure filename obtained by the php function sha1_file()., (*5)

If the uploaded file fail to pass any of these checks it will be handled by the Anax-MVC Exception handler and an error message will be shown., (*6)

In order to test this package you will first need to download the framework 'Anax-MVC' from Github. In this description I will presume that you use GIT bash on your computer. I will also presume that you have Composer installed and that you can use Composer on the command line., (*7)

Start GIT Bash and change the directory so that your command line prompt is present in the working directory you want to use for this download. After the "$" prompt you may want to type the following line:, (*8)

git clone https://github.com/mosbth/Anax-MVC.git, (*9)

After this download you may want to open your text editor (like JEdit or other) and open the file composer.json in the folder Anax-MVC. Add these lines to the end of that file, just before the final curly brace:, (*10)

      "require": {
    "tommy001/mymodule": "dev-master"
}

Now use your command line interface and change the directory into Anax-MVC. Type "Composer validate" to check that your composer.json file is valid. If it checks out, you then type "Composer install" on the command line., (*11)

This will download the package Mymodule into a folder named "vendor" in Anax-MVC., (*12)

In the folder mymodule/webroot there is a file named index.php. Copy that file to the folder Anax-MVC/webroot. Then copy the files from the folder mymodule/view to a new folder named Anax-MVC/app/view/mymodule. And finally copy the files from the folder mymodule/src to a new folder named Anax-MVC/app/src/Mymodule. As mentioned above you will also need to create a writable folder named Anax-MVC/webroot/img/upload., (*13)

In order for simple testing of the upload class there is a rudimentary Sqlite database provided in the mymodule/webroot folder. Move this file to the Anax-MVC webroot folder., (*14)

When you are done with this setup you can point your web browser to index.php, mentioned above and upload a valid image., (*15)

A sanitized version of the original filename is stored in the database, and can e.g. be used to represent the image in a download list. You may wish to add language specific characters and their replacements to the pattern found in line 180 in the class UploadCOntroller., (*16)

The relative disk path of the image is stored with a secure filename in the database, like for example "img/upload/6beb8c7b6305b58cb834161d5a4a383b22101b58.jpg"., (*17)

The Versions

02/03 2015

dev-master

9999999-dev

Class to handle uploading of images within the Anax-MVC framework

  Sources   Download

MIT

The Requires

 

by Tommy Johansson

upload image upload anax-mvc

23/02 2015

v1.0

1.0.0.0

Class to handle uploading of images within the Anax-MVC framework

  Sources   Download

MIT

The Requires

  • php >=5.4

 

by Tommy Johansson

upload image upload anax-mvc