Skip to content
This repository has been archived by the owner on May 5, 2024. It is now read-only.

more then 2 files #74

Open
xensor opened this issue Nov 10, 2015 · 3 comments
Open

more then 2 files #74

xensor opened this issue Nov 10, 2015 · 3 comments

Comments

@xensor
Copy link

xensor commented Nov 10, 2015

it seems to not like more then 2 files at a time.

how can we fix that?

@brandonsavage
Copy link
Owner

Could you use two objects?

On Wed, Nov 11, 2015 at 7:29 AM, Adelowo Lanre notifications@github.com
wrote:

it does not have native support for that but you can always run a loop i
guess


Reply to this email directly or view it on GitHub
#74 (comment)
.

@yepwingtim
Copy link

How can I do that? Im using name="foo[]". How can i access that array?

what i tried so far... new \Upload\File('foo[$i]', $storage);

Thanks

@mrbarletta
Copy link

For those struggling with this

  1. get the latest version
  2. This is my working code

I am using the react-dropzone to send "upload_files" array and this is how to use them

$storage = new \Upload\Storage\FileSystem(__DIR__."/".$sugar_config['upload_dir']);
    $file = new \Upload\File('upload_files', $storage);
    if (count($file)>1) {
        //Multiple file upload
        for ($i=0 ; $i <count($file) ; $i++) {
            // error_log(__FILE__." ". __LINE__." ". $i);
            // Access data about the file that has been uploaded
            $data = array(
                'name'       => $file[$i]->getNameWithExtension(),
                'extension'  => $file[$i]->getExtension(),
                'mime'       => $file[$i]->getMimetype(),
                'size'       => $file[$i]->getSize(),
                'md5'        => $file[$i]->getMd5(),
                'dimensions' => $file[$i]->getDimensions()
            );
$file[$i]->setName('newName');
}
// Single File upload, it doesn't support uploading each file reference
try {
            //Trying to save the File
            $file->upload();
        } catch (\Exception $e) {

            error_log(__FILE__." ". __LINE__." ". print_r($e, 1));

        }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants