I want to upload an image to a local directory on my localhost. This is what I do:
$('#fileupload').fileupload({
dataType: 'json',
add: function (e, data) {
$("#submitentity").on('click', function () {
data.submit();
});
},
done: function (e, data) {
console.log(data);
}
});
As you can see when the upload is done I log the data. The results is the objects (files) :
files: Array[1]
0: File
lastModifiedDate: Fri Aug 30 2013 11:00:12 GMT+0200 (CEST)
name: "Woof.gif"
size: 1820
type: "image/gif"
webkitRelativePath: ""
As you can see the name of the file is "Woo.gif"
. But when I check in my upload folder, the image is saved BUT the filename is changed to "52c87669bbfe0.gif"
. How does this come?
My upload file in view:
<input class="form-control" id="fileupload" type="file" name="files[]" data-url="{{ oneup_uploader_endpoint('gallery') }}" multiple />
I use the jquery file upload plugin that can be found here.
I used the oneupuploaderbundle from Symfony2 and they create the name in the file named 'UniqidNamer.php'
. The original code is:
<?php
namespace Oneup\UploaderBundle\Uploader\Naming;
use Oneup\UploaderBundle\Uploader\File\FileInterface;
class UniqidNamer implements NamerInterface
{
public function name(FileInterface $file)
{
return sprintf('%s.%s', uniqid(), $file->getExtension());
}
}
I changed to my own filename settings.