innostudio / fileuploader

Beautiful and powerful HTML file uploading tool. A jQuery, PHP and Node.js plugin that transforms the standard input into a revolutionary and fancy field on your page.
141 stars 25 forks source link

PHP file upload backend - issues #40

Closed 2maxio closed 5 years ago

2maxio commented 5 years ago
  1. constructors do not return in PHP:
    public function __construct($name, $options = null) {
        $this->default_options['move_uploaded_file'] = function($tmp, $dest, $item) {
            return move_uploaded_file($tmp, $dest);
        };
        return $this->initialize($name, $options);
    }

constructors do not return anything in PHP it should just be like that:

public function __construct($name, $options = null) {
        $this->default_options['move_uploaded_file'] = function($tmp, $dest, $item) {
            return move_uploaded_file($tmp, $dest);
        };
        $this->initialize($name, $options);
    }

  1. binary safe reading of files:
$sp = fopen($file['tmp_name'], 'r');

it should be changed to: $sp = fopen($file['tmp_name'], 'rb'); by adding "b" flag for fopen mode, as php documentation suggests: https://www.php.net/manual/en/function.fopen.php

  1. code should not count in loop

    for($i = 0; $i < count($this->field['input']['name']); $i++) {
  2. PHPdoc have different structure, than used in code:

     * @param $crop {boolean, Array} crop property

should be:

     * @param boolean|array $crop crop property

because IDE can not read current one

  1. probably it would be good idea to put PHP code through some kind of static analysis tool, I use PHP, because as of now I have to disable static analysis because of number of errors like: unnecessary double quotes, non strict comparison etc.
innostudio commented 5 years ago

@2maxio thank you that you noticed this.

  1. construct returns a value for the class that extends the FileUploader class. E.g: `$initStatus = parent::construct();`

  2. for the Windows, sometimes it can give an error so we will change it

  3. $this->field['input']['name'] is an unchanged variable

  4. we used our own comments to make it readable.

  5. thank you. By the way, maybe you don't have to open the class.fileuploader.php and to make there any changes because of the future updates.