Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use two upload zones #59

Closed
mj-bdl opened this issue Oct 9, 2013 · 9 comments
Closed

Use two upload zones #59

mj-bdl opened this issue Oct 9, 2013 · 9 comments
Labels

Comments

@mj-bdl
Copy link

mj-bdl commented Oct 9, 2013

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.

@sheeep
Copy link
Contributor

sheeep commented Oct 9, 2013

You can use more than one mapping.

# app/config/config.yml

oneup_uploader:
    mappings:
        images:
            frontend: dropzone
        documents:
            frontend: dropzone

Be sure to set the correct endpoint in your templates:

{{ oneup_uploader_endpoint('images'); }} #for image uploads
{{ oneup_uploader_endpoint('documents'); }} #for document uploads

@mj-bdl
Copy link
Author

mj-bdl commented Oct 9, 2013

Thanks for the quick response.

Perfect. But my question now is: How can I control that in the first one only images are allowed to be uploaded and in the second one only documents (no images)?

Thank you again.

@sheeep
Copy link
Contributor

sheeep commented Oct 9, 2013

Take a look at the configuration reference. You can use the built in mime type validators:

# app/config/config.yml

oneup_uploader:
    mappings:
        images:
            frontend: dropzone
            allowed_mimetypes: ["image/gif", "image/jpeg", "image/png", ...]
        documents:
            frontend: dropzone
            allowed_mimetypes: ["application/pdf", ...]

Note:

Do not use allowed_extensions or disallowed_extensions. These are legacy options and will be removed.

@sheeep sheeep mentioned this issue Oct 9, 2013
7 tasks
@mj-bdl
Copy link
Author

mj-bdl commented Oct 9, 2013

Oh that's great!! because I am using Dropzone.js and it also gives you the option to filter type, but I am calling it for images and documents, and I couldn't do it. Your solution is perfect.

The last problem I have is that I am using dropzone.css for both, and I need different views for each one. Could you help me with this?

Thanks!

@sheeep
Copy link
Contributor

sheeep commented Oct 9, 2013

I'm afraid this does not lie within the scope of this bundle. But the CSS file assigns its rules to the class .dropzone. Why don't you just set two different classes for the two dropzones and style them accordingly?

Anything that is not about the backend part, should be asked either on the dropzone repo if it is an issue or Stackoverflow for questions. :)

@mj-bdl
Copy link
Author

mj-bdl commented Oct 9, 2013

Ok, y have changed the css and it works perfect!

Also, I have changed the allowed types in app/config/config.yml and the files that are not specified there are not uploaded, but when I execute it in chrome, for instance (remember, I am using dropzone.js) looks like it has been uploaded (it shows a green tick). That's why I need to use different dropzone.js for each uploader zones, so I can specify in them the allowed types.

@sheeep sheeep closed this as completed Oct 15, 2013
@saitx
Copy link

saitx commented Oct 21, 2013

@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. I havent been able to get the value of the selected in the EventListener.

@armilleiwilliam
Copy link

I followed the instructions above but I have the following error:
'An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "_uploader_upload_documents" as such route does not exist.")'

This is my code:
oneup_uploader:
mappings:
documents:
frontend: blueimp
namer: acme_demo.custom_namer
gallery:
frontend: blueimp
allowed_mimetypes: ["image/gif", "image/jpeg", "image/png"]

In the routing.yml is the following:
oneup_uploader:
resource: .
type: uploader

In my twig:
{{ oneup_uploader_endpoint('documents') }}

I tried also to substitute "documents" with "images" but it seems it takes only "gallery". Any idea?

@armilleiwilliam
Copy link

Ok, I've found the solution. I had to clear the cache, even if it seems weird to me, maybe because when symfony2 imports the config.yml into config_dev.yml it retrieves the copy from the cache instead of the original copy just modified. The bundle is very good ;-)

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

No branches or pull requests

4 participants