Giter VIP home page Giter VIP logo

1up-lab / oneupuploaderbundle Goto Github PK

View Code? Open in Web Editor NEW
602.0 28.0 177.0 1.03 MB

This Symfony bundle provides a server implementation for handling single and multiple file uploads using either FineUploader, jQuery File Uploader, YUI3 Uploader, Uploadify, FancyUpload, MooUpload, Plupload or Dropzone. Features include chunked uploads, orphanages, Gaufrette and Flysystem support.

License: MIT License

PHP 100.00%
php symfony fineuploader gaufrette chunked-uploads plupload dropzone

oneupuploaderbundle's Introduction

OneupUploaderBundle

CI Total Downloads

The OneupUploaderBundle for Symfony adds support for handling file uploads using one of the following JavaScript libraries, or your own implementation.

Features included:

Documentation

The entry point of the documentation can be found in the file docs/index.md

Read the documentation for main

Upgrade Notes

  • Version 5.0.0 supports now Symfony 7 (kudos to @evertharmeling and @joesenova), see #436! Symfony 4 and PHP 7 support was dropped.
  • Version 4.0.0 supports now Flysystem 2 & 3 (kudos to @m2mtech), see #412! Flysystem 1 and OneupFlysystemBundle < 4.0 support was dropped.
  • Version 3.2.0 supports now Symfony 6 (kudos to @pich), see #421! PHP 7.2/7.3 support was dropped.
  • Version 3.0.0 supports now Symfony 5 (kudos to @steveWinter, @gubler, @patrickbussmann, @ErnadoO and @enumag, see #373! Symfony 3.x support was dropped.
  • Version 2.0.0 supports now Symfony 4 (Thank you @istvancsabakis, see #295)! Symfony 2.x support was dropped. You can also configure a file extension validation whitelist now (PR #262).
  • Version 1.5.0 supports now Flysystem (Thank you @lsv! PR #213) and is no longer compatible with PHP 5.3 (it's EOL since August 2014 anyway).
  • Version v1.0.0 introduced some backward compatibility breaks. For a full list of changes, head to the dedicated pull request.
  • If you're using chunked uploads consider upgrading from v0.9.6 to v0.9.7. A critical issue was reported regarding the assembly of chunks. More information in ticket #21.
  • Error management changed in Version 0.9.6. You can now register an ErrorHandler per configured frontend. This comes bundled with some adjustments to the blueimp controller. More information is available in the documentation.
  • Event dispatching changed in Version 0.9.5. The dispatching is now handled in the upload* functions. So if you have created your own implementation, be sure to remove the call to the dispatchEvents function, otherwise it will be called twice. Furthermore no POST_UPLOAD event will be fired anymore after uploading a chunk. You can get more information on this topic in the documentation.
  • Event names changed in Version 0.9.3, update your EventListener accordingly.

License

This bundle is under the MIT license. See the complete license in the bundle:

LICENSE

Reporting an issue or a feature request

Issues and feature requests are tracked in the Github issue tracker.

When reporting a bug, it may be a good idea to reproduce it in a basic project built using the Symfony Standard Edition to allow developers of the bundle to reproduce the issue by simply cloning it and following some steps.

oneupuploaderbundle's People

Contributors

ahmadtawila avatar akashgosai avatar albenik avatar andreybolonin avatar biozshock avatar brandonpearson23 avatar bronek89 avatar bytehead avatar deviprsd avatar diegotham avatar domojonux avatar ernadoo avatar evertharmeling avatar extreme avatar funkemt avatar giosh94mhz avatar lchrusciel avatar lctrs avatar lsv avatar m2mtech avatar mediafigaro avatar mhlavac avatar mitom avatar ndench avatar ribeiropaulor avatar schyzophrenic avatar sheeep avatar snarktooth avatar thomaslandauer avatar tigr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

oneupuploaderbundle's Issues

Pass the request to validation event

Could you also pass the request to the validation? It is useful if the validation is not limited to the file itself, but also includes database checks which requires attributes sent along with the file.

Getting the value of additional fields in form to choose Group/Type.

@sheeep Thanks for the bundle, I have got everything working until now on blueimp. I have added an additional input field(selection) as to let the me choose the type(group1, group2) of the image for database entry (no folder change that might be later). I havent been able to get the value of the selected in the EventListener.

Unable to use id and path of the uploaded image

Hi ,
First of all thanks for creating this awesome bundle, I am facing an issue when I try to manipulate the json response ( as mentioned in doc )
when I use ,
$response['url'] = $uploadedImage->getUrl();
I am getting
Call to a member function getUrl() on a non-object

how can I add the url to the response ?

regards

Make it possible to return the link to the uploaded file

Currently neither this bundle nor the standard implementation of the PHP-Server of valums/file-uploader returns relevant data other than true on success. Taken into account that you possible want to directly display an uploaded image or place a link to an uploaded file this uploader should definitely return something relevant like the name coming from the Namer implementation set in configuration.

Is there a working demo anywhere?

Your bundle looks very nice and appears to do most of what I need.

However, I have spent the last 3 days trying to make it work. I'm probably missing something simple, but I can't figure out what it is (or even the correct questions to ask).

The documentation may be helpful to someone with extensive experience with Symfony, but this is my first Symfony project and I seem to be continually getting stuck on minor issues (configuration problems, not knowing the correct name for what I need, not knowing what questions to ask, etc).

It is frustrating when I know what I want to do (and know how to do it in regular PHP, C or Perl), but I can't figure out how to put all the necessary Symfony pieces together to make things work. I could have written a simple upload handler in regular PHP and gotten everything working in less than a day. However, I've committed to using Symfony on this project and am trying to get "unstuck" on how to make this bundle work.

So far, instead of this being a "RAD" project, it has been "SAD" (Slow Application Development).

It would be most helpful if there was a complete working demo someplace, along with all the relevant source code and configuration details.

If none is currently available, answers to the following questions would be helpful:

  1. Can this bundle be used with the regular form construction method like:
  $builder->add('files[]', 'file')

or is it necessary to embed the raw html <input... > in the form?

The $builder->add() method complains when I try it use 'files[]' as a name, which made me wonder about whether you can use this method. Is the 'files[]' name necessary or will it work with a different name?

  1. The documentation says it will "work out of the box" but then goes on to talk about setting up an endpoint...
 {{ oneup_uploader_endpoint('gallery') }}

So if you take the mapping described before, the generated route name would be _uploader_gallery

However, the generated name is actually: _uploader/gallery/upload

Is this a mistake in the documentation or am I doing something wrong?

Where is the module that is mapped to this route? Is this part of this bundle or do I need to write that part myself?

  1. Do I really need to configure a service -- from what I read, it appears to be optional. Does your bundle handle the upload automatically without the necessity of configuring a service? If so, where are the files stored by default?

  2. Why is the service configuration in XML when the other configs are in YAML? I've been searching thru Google and Symfony docs for several weeks and have been unable able to find a good answer to this. With another project, I could not get the XML config to work, so I finally managed by translating their XML to YAML (another PITA). All the docs say you can use YAML or XML, but never illustrate how to switch between them. It seems like there should an easy way to use both. This is a good example of a simple problem with a difficult to find solution.

The answers to these questions may be obvious once you know Symfony well, but I'm still trying to figure out everything. I've gotten the blueimp upload package to work by itself, but I cannot get it working with this bundle.

Any help would be appreciated.

Missing documentation about default upload directory

Please improve documentation about default directory where files are stored - I've just lost an hour looking for it and getting exceptions. Finally I've found your great explanation about configuring bundle (#51 (comment)) and created /web/uploads/gallery directory. So it would be great if you could add to main documentation info about the need to create this folder (with correct permissions on Linux).

can't inherit abstract function error

I am using fineuploader and it is working on my dev box - when I upload on production server, file upload fails with this JS console error

POST http://.com/_uploader/image/upload 500 (Internal Server Error) app.js:5632
[FineUploader] Error when attempting to parse xhr response text (SyntaxError: Unexpected end of input)

and I see this in my server error log
PHP Fatal error: Can't inherit abstract function Oneup\UploaderBundle\Uploader\Response\ResponseInterface::assemble() (previously declared abstract in Oneup\UploaderBundle\Uploader\Response\AbstractResponse) in /var/www/vhosts/.com/webdir/vendor/oneup/uploader-bundle/Oneup/UploaderBundle/Uploader/Response/AbstractResponse.php on line 8

Use two upload zones

Hi, I am using this bundle with Dropzone. What I am wondering now is how to use two:

  • one to upload only images and
  • another one to upload only documentation (doc, pdf, ...).

How can I handle this?

Thanks in advance.

IE8 & Plupload (html4) strange behavior

There is an issue when using Pluploader (HTML4 apporach) with this bundle on IE8 browser.

When file is uploaded, it's correctly stored, but new window "download file" appears. This file is in fact a JSON response coming from the PluploadController. It seems that IE8 is not accepting the "application/json" Content-Type.

I have fixed this in my private fork, only in upload action response, but I see this as a possible bigger issue (affecting all JsonResponses). I am not sure if this is the only Plupload issue (other uploaders might be also affected). If so, it might be a better idea to have a wrapper over the JsonResponse object somewhere after the action (custom kernel EventListener?), but it depends on your approach.

This ugly hack seems to work for IE8 (it is the targeted browser.. - no comments) and regexp rule keeps "normal" browsers with correct Content-Type header.

If you need, I can propose this hack as a pull request.

PS. I've tested "text/plain" and "text/json" and both works, but I see "text/json" as a bit nearer to the correct one.

public function upload()
{
(...)
        $response = new JsonResponse($response->assemble());

        //hacking the IE8 strange behavior on application/json Content-Type header
        if (($ua = $this->container->get('request')->server->get('HTTP_USER_AGENT'))
                && (false !== stripos($ua, 'MSIE'))) {
            $response->headers->set('Content-Type', 'text/json');
        }

        return $response;

}

_uploader/gallery/upload 500 (Internal Server Error) jquery.js

Hi,

Thank's for the bundle !

I tried to use with blueimp.

config.yml

oneup_uploader:
    mappings:
        gallery:
            frontend: blueimp

services.yml

fa_user.upload_listener:
    class: Fa\UserBundle\EventListener\UploadListener
    arguments: [@doctrine]
    tags:
        - { name: kernel.event_listener, event: oneup_uploader.post_upload, method: onUpload }

UploadListener.php

<?php
namespace Fa\UserBundle\EventListener;

use Oneup\UploaderBundle\Event\PostPersistEvent;

class UploadListener
{
    public function __construct($doctrine)
    {
        $this->doctrine = $doctrine;
    }

    public function onUpload(PostPersistEvent $event)
    {

    }
}

edit.html.twig

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="{{ asset('js/jquery.ui.widget.js') }}"></script>
<script type="text/javascript" src="{{ asset('js/jquery.iframe-transport.js') }}"></script>
<script type="text/javascript" src="{{ asset('js/jquery.fileupload.js') }}"></script>
<script type="text/javascript">
$(document).ready(function()
{
    $('#fileupload').fileupload({});
});
</script>

<input id="fileupload" type="file" name="files[]" data-url="{{ oneup_uploader_endpoint('gallery') }}" multiple />

And when i choose a file, i have a "500 (Internal Server Error) jquery.js:8706"
I don't understand why ...
Please help :)

Thanks

Big files are not uploading (FileNotFoundException)

Hello. I am experiencing an issue, which has strange behavior.

SF2.3

I am uploading with FineUploader. Big images >5mb Images are not uploading...

request.CRITICAL: Uncaught PHP Exception Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException: "The file "" does not exist" at /var/www/acme/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php line 115 {"exception":"[object] (Symfony\\Component\\HttpFoundation\\File\\Exception\\FileNotFoundException: The file \"\" does not exist at /var/www/acme/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php:115)"} []

Update to latest code fixed the issue

Asynchronous backend file-uploading

#53 contains 2 issues, it will be easier to follow them like this.

An other option that came to my mind, which might fall out of the scope of this bundle and would only improve things for those with other than Local backends is that the tmp backend could be also used as a web-server too, and upload instead of actually uploading could just give them information of the file, such as the key and so. Maybe the upload should rather call a handler as the validation does (except using only one) and if there is no handler fall back to the default? Using that one could create a background job that would copy over the file to the desired location, looked it up in the database, changed the location for it and then removed it from temp.

Reassembling the file during upload

Do you know of any reason why the file couldn't be reassembled during the upload (after each successful piece)?

With bigger files it can take pretty long to go through all the chunks at once and then upload it. This can easily result in a time-out, especially if you also have to upload to a remote filesystem.

Reassembling the files on the go could distribute this task through the upload.

Chunked files won't reassemble due to getInnerIterator call

@p365labs:

Hi, I'm testing the bundle with Symfony 2.1.6 and the last bundle tag version 0.9.7 with bluimp as frontend, but I have I problem with chunks upload.
The problem is that the bundle don't re-assemble the file leaving the chunks not assembled. I've tried to debug a bit and I've noticed that the problem is $iterator = $chunks->getIterator()->getInnerIterator(); in ChunkManager.php.
If I remove the getInnerIterator() leaving only getIterator() all works fine : the file is correctly assembled and the chunks removed. Am I doing something wrong ?

original: a comment in #21

Access to the original file in events

Hey,

Could you also pass the original file to the events?

The reason is that the namer gets called before the events, so what we get is already a renamed file, so we don't know the original name. For me it would be important to know the exact filename (case-sensitive) and store it in the db with other properties, but rename the files to a reasonable one.

If the file is not chunked and there is only 1 in the request, this can be done by accessing it directly in the request, however it won't work for chunked files, or if there are more files/request.

It would be possible to manage the database thing in the namer too, but I'd need to fetch the entity again in postPersist to generate a proper response.

Let me know your opinion, maybe there is a better way. Thanks.

Chunk uploading and load balancing - how is it supposed to work

Hi, I'm prepping my webapp for horizontal scaling (from 1 server to 3+) and I was really happy to see info about chunked upload behind load balancers in changelog in version 1.0. But the more I look at the code and test on my local env I can't understand how it is supposed to work.

You introduced gaufrette as a storage so I thought I would be able to store chunks on S3, but the only storage supported is local storage because "The filesystem used as chunk storage must implement StreamFactory". So how is it different from previous approach since we use local stream storage for chunks?

So with 3MB file with 1 MB chunks they will be sent: 1st to Server#1, 2nd to Server#2 and 3rd to Server#3 - how can Server#3 assemble the file when all chunks are distributed to other servers? And how to send the file later to S3 when moving a file from stream to stream loads the whole file into memory (with bigger upload I can run out of memory for PHP).

Make the getFiles method of OrphanageStorage public

Hello, nice bundle!

In regards to using orphanage will upload all the file from previous visits, can we just use the getFiles() method from the service (oneup_uploader.orphanage.{mapping}) and decides what to do with the existing files instead?

Eg. I can get the files uploaded (if any) when the user did upload some files previously. And its up to own implementation to either redisplayed the files in template/remove it from within the controller.

The issue with this is I see getFiles method is protected. Any advice on this? Thanks

Exception during the rendering of a template

Hi !

I'm trying to configure this bundle to use JQuery File Upload.
So, I read this doc : https://github.com/1up-lab/OneupUploaderBundle/blob/master/Resources/doc/index.md and I configured my app but I got an error :

 An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "_uploader_upload_gallery" as such route does not exist.") 

It seams I do some mistakes during Step 3 (https://github.com/1up-lab/OneupUploaderBundle/blob/master/Resources/doc/index.md#step-3-configure-the-bundle).

Could you help me to resolve that ?

My config.yml file :

 # UploaderBundle configuration.
 oneup_uploader:
     mappings:
         gallery: ~

My Twig template :

 <!-- Picture uploader -->
 <input  id="fileupload" 
            type="file" 
            name="files[]" 
            data-url="{{ oneup_uploader_endpoint('gallery') }}" multiple />

Thanks in advance,

Using OneupUploadBundle with Dropzonejs

Hi,

I am having an issue using OneupUploadBundle and Dropzonejs in my project. I have an Entity which has an attribute with a OneToMany relation to another Entity. In that attribute I store the attached files I need to upload with Dropzonejs. So, in my Controller, I receive a form in which a fill all the other atributes of the Entity, and another form in which I upload the attached files (using Dropzonejs). My question is that I have no idea of how can I save the attached files in my entity.

Where are they saved when they are uploaded? how can I assign them to my OnetoMany relation?

Hope you understand my question.

Thanks in advance.

Empty Upload Response - Using BlueImp

Hello,

I am using blueimp.
After following the setup documentation I can upload files and also view them on my local disc. However, blueimp doesn't show me that the file has been uploaded successfully. While searching for the potential reason I discovered that the upload-response is empty. Afaik, blueimp requires that the response contains a JSON-encoded state message according to https://github.com/blueimp/jQuery-File-Upload/wiki/Setup#using-jquery-file-upload-ui-version-with-a-custom-server-side-upload-handler

Do I have to take care of that on myself? Or might the error be somewhere else?

[RFC] Structural changes in the future

During the development of the 1.0 release of this bundle, a nice discussion about the current architectural decisions arose. (#58)

This RFC should address these concerns by covering the following topics:

  • In which way should this bundle be structured in the future?
  • Should the core of this bundle be decoupled from its features?
  • What belongs to the core?
  • What is a feature?
  • Is there a proper way of implementing decoupled features in Symfony2 bundles?

dynamic upload path based on user ID ?

Is it possible in the UploaderBundle (or via Guafrette) to upload to a dynamic path based on the user id of the signed in user?

For example - I have a site with many users who upload photos to /images/users/00000

I could do a file move after upload but was wondering if it is possible to do this automatically as part of the upload path.

Can't save data from Request. Using Blueimp + Symfony2.3

Hello... First i wanna thank for such a great Work making this amazing Bundle.
Currently im using Blueimp as a Frontend i configure all things on my views, and works very fine.

But troubles starts when i want to save data send from Blueimp to a Doctrine Entity.

I follow all steps in documentation but i get lost to implement UploadListener.

Here is my code of UploadListener.

<?php

namespace Inti\RegistroBundle\EventListener;

use Oneup\UploaderBundle\Event\PreUploadEvent;
use Oneup\UploaderBundle\Event\PostUploadEvent;

use Doctrine\ORM\Event\LifecycleEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\RedirectResponse;

use Inti\RegistroBundle\Entity\Archivo;

class UploadListener 
{
    private $container;
    protected $em;

    public function __construct(ContainerInterface $container, \Doctrine\ORM\EntityManager $em)
    {
        $this->container    = $container;
        $this->em           = $em;
    }

    public function onUpload(PostUploadEvent $event)
    {
        $request    = $event->getRequest();
        $response = $event->getResponse();
        $session    = $request->getSession();

        $gallery    = $request->get('gallery');
        $file       = $event->getFile();        

        //this is my Entity called "Archivo" and i wanna know how save Data from uploaded Picture to this Entity
        $archivo    = new Archivo();

        $archivo->setName($file->getFilename());
        $archivo->setType($file->getType());
        $archivo->setDescription('Some random text');
        $archivo->setPath($file->getPath());

        $this->em->persist($archivo);
        $this->em->flush();

        $response['files'] = array(
            'name' => $file->getFileName(),
            'size' => $file->getSize(),
            'url'  => 'http://mywebserver/route/to/image.jpg',
            'delete_url'   => "http://nourltodelete.com",
            'delete_type' => 'DELETE'
            );
    }
}

There is PART of my View code:

<div class="tab-pane" id="fotos">
      <div class="row">
        <div class="span6">
          <span class="btn btn-success btn-file btn-small fileinput-button">
            <i class="icon-plus icon-white"></i>
            <span>Subir archivos...</span>
            <input id="fileupload" type="file" name="files[]" multiple>
          </span>
          <button type="submit" class="btn btn-primary btn-small">
            <i class="icon-upload icon-white"></i>
            <span>Comenzar Subida</span>
          </button>
        </div>
      </div>
      <div class="row">
        <div class="span6">
          <br>
          <div id="progress" class="progress progress-stripped">
            <div class="bar"></div>
          </div>
        </div>
      </div>     
        <!--Contenido de FOTOS-->
      <div class="row">
      </div>
      </div>
         <p class="pull-right" id="form-botones">
            <input type="submit" value="Guardar" class="btn-primary btn btn-small" name="guardar" />
            <input type="button" value="Cancelar" class="btn btn-small" onclick="location.href='{{ path('visitadocente')}}'" name="cancelar"/>
        </p>
    </div>
  </div>
</form>
{% endblock %}
{% block mapScripts %}
<!-- The Load Image plugin is included for the preview images and image resizing functionality -->
<script src="http://blueimp.github.io/JavaScript-Load-Image/js/load-image.min.js"></script>
<!-- The Canvas to Blob plugin is included for image resizing functionality -->
<script src="http://blueimp.github.io/JavaScript-Canvas-to-Blob/js/canvas-to-blob.min.js"></script>
<script src="{{ asset('/js/fileupload/jquery.iframe-transport.js') }}"></script>
<script src="{{ asset('/js/fileupload/jquery.fileupload.js') }}"></script>
<script src="{{ asset('/js/fileupload/jquery.fileupload-process.js') }}"></script>
<script src="{{ asset('/js/fileupload/jquery.fileupload-image.js') }}"></script>
<script src="{{ asset('/js/fileupload/jquery.fileupload-validate.js') }}"></script>
<script>
$(document).ready(function (event) {
  'use strict';
  // Change this to the location of your server-side upload handler:
  //var url = "{{ path('archivo_create') }}",

   var uploadButton = $('<button/>')
      .addClass('btn btn-primary btn-small')
      .prop('disabled', true)
      .text('Procesando...')
      .on('click', function () {
          var $this = $(this),
              data = $this.data();
          $this
              .off('click')
              .text('Cancelar')
              .on('click', function () {
                  $this.remove();
                  data.abort();
              });
          data.submit().always(function () {
              $this.remove();
          });
      });
  $('#fileupload').fileupload({
      url: '{{ oneup_uploader_endpoint("gallery") }}',
      dataType: 'json',
      limitMultiFileUploads: 4,
      autoUpload: false,
      acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
      maxFileSize: 4000000, // 4 MB
      // Enable image resizing, except for Android and Opera,
      // which actually support image resizing, but fail to
      // send Blob objects via XHR requests:
      disableImageResize: /Android(?!.*Chrome)|Opera/.test(window.navigator.userAgent),
      previewMaxWidth: 200,
      previewMaxHeight: 200,
      previewCrop: true
  }).on('fileuploadadd', function (event, data) {
      data.context = $('<div class="span3"/>').appendTo('#files');
      $.each(data.files, function (index, file) {
          var node = $('<p/>').append($('<span/>').text(file.name));
          node.append('<textarea name="descripcion-foto"/>');
          if (!index) {
              node
                  .append('<br>')
                  .append(uploadButton.clone(true).data(data));
          }
          node.appendTo(data.context);
      });
  }).on('fileuploadprocessalways', function (event, data) {
      console.dir(data);
      var index = data.index,
          file = data.files[index],
          node = $(data.context.children()[index]);
      if (file.preview) {
          node
              .prepend('<br>')
              .prepend(file.preview);
      }
      if (file.error) {
          node
              .append('<br>')
              .append(file.error);
      }
      if (index + 1 === data.files.length) {
          data.context.find('button')
              .text('Subir')
              .prop('disabled', !!data.files.error);
      }      
  }).on('fileuploadprogressall', function (event, data) {
      $('#progress .bar').css( 'width', '0%' );
      var progress = parseInt(data.loaded / data.total * 100, 10);
      $('#progress .bar').css( 'width', progress + '%' );

  }).on('fileuploaddone', function (event, data) {
      console.log('Archiv subido');
      $.each(data.files, function (index, file) {        
          var link = $('<a>')
              .attr('target', '_blank')
              .prop('href', file.url);
          $(data.context.children()[index])
              .wrap(link);
      });

  }).on('fileuploadfail', function (event, data) {
      console.log('Archiv fallado');
      $.each(data.files, function (index, file) {        
          var error = $('<span/>').text(file.error);
          $(data.context.children()[index])
              .append('<br>')
              .append(error);
      });

  }).prop('disabled', !$.support.fileInput)
      .parent().addClass($.support.fileInput ? undefined : 'disabled');
});
</script>

Also in my view when i click to Upload a Picture... get this info in Console.log...

POST http://mywebserver/app_dev.php/_uploader/gallery/upload 500 (Internal Server Error)
XHR finished loading: "http://mywebserver/app_dev.php/_uploader/gallery/upload".
console.log('Archiv fallado') -> "Archiv Fallado"

Really appreciate some help...

Nick Palomino.

allowed_mimetypes, the file "" does not exist

I set the allowed_mimetypes for my mapping, upload a file, the response I get is a 500 Internal Server Error , message : the file "" does not exist . I guess the uploaded file never makes it to the upload folder and the mimeguesser throws that exception.

oneup_uploader:
    mappings:
        xls:
            frontend: blueimp # or any uploader you use in the frontend
            error_handler: oneup_uploader.error_handler.blueimp
            allowed_mimetypes:
                - 'application/vnd.ms-excel'
                - 'application/msexcel'
                - 'application/x-msexcel'
                - 'application/x-ms-excel'
                - 'application/x-excel'
                - 'application/x-dos_ms_excel'
                - 'application/xls'
                - 'application/x-xls'

Post persist Event will not be fired if using the Orphanage

Currently the only point where the POST_PERSIST Event will be fired is in UploadCotroller::upload(). If you're using an Orphanage you have to manually call the Orphanage::uploadFiles method. In addition, the PostPersistEvent always gets a Request object, which is not really useful when using the Orphanage.

Either create a new Event which will be fired after the files where successfully uploaded by the Orphanage or move the request parameter to an option array, like in PostUploadEvent.

getMaxUploadSize() in my view

I have a question, is there a way to get the max upload size value in my view ? So I can configure the blueimp/jquery uploader maxFileSize with the value ?

Impossible to add EventListener - Plupload

Hello, not sure about that but it seems PostUploadEvent are not working. As it's said in the documentation, I registered a new service routing to a custom EventListener (which is in my main bundle). Any idea ?

Get User

Hello,

I've been looking for a while some informations.
I'd like to know what are the datas returned by $request, $response etc, in order to be able to get and use it in my event listeners.
Actually, I want to persist my files datas with the user id.

I'm a beginner at Symfony, would be nice a bit more explanations :)

Refactor the Storage system so using an Orphanage won't lead to redundant code

Currently both classes implementing StorageInterface and classes implementing OrphanageInterface implement their own access points for uploading and deleting files.
It should be considered to refactor this way so we'd have an abstract parent-class for accessing the filesystem (or orphanage).

Maybe it is possible to inject either the Orphanage or the Gaufrette filesystem depending on the configuration value use_orphanage.

Be sure to also fix #1

onUpload UploadListener notwork!!

hi, i've problem when i try to use listener. Maybe is my fault. I'm in symfony 2.3 with postgresSQL. I try to use that with sonata media.

        $request = $event->getRequest();
        $file = $this->getFiles($request->files);
        die(var_dump($file));
        $gallery = $request->get('gallery');
        $file = $request->files->get('upload');
...etc

my service

services:
  ## post pre update event after persist object
  media.upload_listener:
      class: 'Kdig\MediaBundle\EventListener\UploadListener'
      arguments: [ '@service_container' ]
      tags:
          - { name: container.event_listener, event: oneup_uploader.post_persist, method: onUpload }

"die()" not work.
Can you explain me why?

thanks in advance
regards
Stefano

Chunked upload validated incorrectly (max_size)

Hi,

I am using OneupUploaderBundle with Plupload as frontend implementation, using the html5 runtime.

Uploading small files works as expected, but I'm having trouble with uploading big files (using chunked uploads). The problem is that either the $request->get('chunks') (and chunk) parameters or the $request->files are not recognized. Or both.

I tried enabling/disabling Pluploads multipart setting, or using the html4 runtime.

Here are my test results.

                Files recognized            Chunks params recognized            Request content-type            As expected
html4
 - small file   yes                         n/a                                 multipart/form-data             YES
 - large file   no                          no                                  multipart/form-data             NO (2 issues) 

html5 (multipart=false)
 - small file   no                          n/a                                 application/octet-stream        NO (1 issue)
 - large file   no                          yes                                 application/octet-stream        NO (1 issue)

html5 (with multipart=true)
 - small file   yes                         n/a                                 multipart/form-data             YES
 - large file   no                          no                                  multipart/form-data             NO (2 issues)

The problem is that there is no situation at all where chunked uploading works.

It looks to me that a multipart/form-data generally works better, so it would be great to have a chunked file to be recognized in a multipart request.

It seems that there is missing some magic in PluploadController.php, but I don't have that much experience with multipart requests and chunked uploading...

Can't create error handler

When i define error service like this:

use Symfony\Component\HttpFoundation\File\Exception\UploadException;
use Oneup\UploaderBundle\Uploader\ErrorHandler\ErrorHandlerInterface;
use Oneup\UploaderBundle\Uploader\Response\ResponseInterface;

class UploadErrorHandler implements ErrorHandlerInterface
{
    public function addException(ResponseInterface $response, UploadException $exception)
    {
        $message = $exception->getMessage();
        $response['error'] = $message;
    }
}

I'm getting this

FatalErrorException: Compile Error: Declaration of UploadErrorHandler::addException() must be compatible with Oneup\UploaderBundle\Uploader\ErrorHandler\ErrorHandlerInterface::addException(Oneup\UploaderBundle\Uploader\Response\AbstractResponse $response, Exception $exception)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.