PerfectlyNormal / tinymce-rails-imageupload

Image upload plugin for TinyMCE and Rails with the asset pipeline
MIT License
149 stars 153 forks source link

Upload file type error #20

Closed harold-s closed 11 years ago

harold-s commented 11 years ago

Hello,

I have read the documentation and I'm sorry if I missed it but I'm looking for a way to display an error to the user if the file is not an image. (jpg, png, gif)

I see two ways : Verify the extension before upload return a JSON error.

My project is already checking the extension and refuses non image file but if I return an empty JSON or an error, the upload form just hangs without doing anything.

Thanks a lot fort this very useful project by the way. I'm not very familiar iwth github projects and I have translated to French the JS. Could I send them you by email ?

Regards,

Harold

PerfectlyNormal commented 11 years ago

Hi.

There is currently no proper way of handling errors such as file extensions, but it shouldn't be too hard to get something working. The best way in my opinion would be to return JSON with an error message, since that could easily be extended to handle other kinds of errors on the server as well.

The JSON is parsed and handled in the uploadDone function in dialog.html, but this should probably be moved around a bit and cleaned up if we end up with a lot of code here.

You are welcome to give it a go, or I'll see if I can try something, although it probably won't be until the weekend.

Feel free to send me translations at perchr@northblue.org, and I'll make sure to get them added.

PerfectlyNormal commented 11 years ago

Added some error handling to master now, but waiting on some new translations before releasing a new version. If you still want the french translations, please translate the new strings as well.

harold-s commented 11 years ago

Thanks again !