V
V
Vladimir2016-05-17 07:18:20
symfony
Vladimir, 2016-05-17 07:18:20

Uploading files in Symfony?

The documentation on this leaves much to be desired, and the vich/uploader-bundle brings along a bunch of dependencies and litters the entity with unnecessary fields.
Are there alternatives?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2016-05-17
@devwho

The documentation on this leaves much to be desired.

What do you want from documentation? In the most primitive version, you have already been told:
public function uploadFile(File $file) {
     $file->move($this->uploadDir, $this->generateUniqName($file));
}

The path is injected from the container as a parameter.
services:

    file_uploader:
        class: FileUploader
        arguments: ['%kernel.root_dir%/../web/uploads']

and instead, you can use FlySystem the same as an abstraction over the file system. Then everything is convenient.
i also don't like vich uploader bundle so i use my own solution. The other day, a relatively decent upload bundle was posted in the gitter symphony: https://github.com/atom-azimov/uploader-bundle but I did not check it in battle, although ideologically it seems to be correct.

A
Alexey Skobkin, 2016-05-17
@skobkin

You can try IPhpFileStoreBundle . It is quite old, not very flexible (although you can partially expand it yourself), but it copes with its task.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question