1. Go to this page and download the library: Download hdevs/uploader-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hdevs / uploader-bundle example snippets
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new HDevs\UploaderBundle\HDevsUploaderBundle(),
);
// ...
}
// ...
}
//Entity
use HDevs\UploaderBundle\Annotation\Uploadable;
use HDevs\UploaderBundle\Annotation\UploadableProperty;
/**
* @ORM\Table(name="post")
* @Uploadable()
*/
class Post
{
// Other fields
/**
* @var string
* @ORM\Column(name="image", type="string", length=255)
*/
private $image;
/**
* @var \DateTime
* @ORM\Column(name="updated_at", type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @var File
* @UploadableProperty(field="image", path="uploads/posts")
*/
private $file;
}
//FormType
use Symfony\Component\Form\Extension\Core\Type\FileType;
$builder->add('file', FileType::class, [
'label' => 'global.image'
]);
html
<!-- View -->
<img src="{{ asset(post.file.pathname) }}">
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.