Tag: files
-
Web API 2 – ExceptionMessage=No MediaTypeFormatter is available to read an object of type ‘HttpPostedFileBase’ from content with media type ‘multipart/form-data’.
Hi everyone, I ran into the following error while trying to get image uploads working with Web API 2: ExceptionMessage=No MediaTypeFormatter is available to read an object of type ‘HttpPostedFileBase’ from content with media type ‘multipart/form-data’. I had been trying to copy the following from an mvc controller in another project: public IHttpActionResult Upload(HttpPostedFileBase file,…
-
Dragging a File from File Explorer Causes Google Chrome to Crash
Hey everyone, A team member found an interesting bug today that caused chrome to go non-responsive. The cause was simply dragging a file from the file explorer onto a drag and drop upload area. It is reproducible on every site I’ve tested, including Gmail and Dropbox. Reproduce Go to https://mail.google.com Click compose Click attach files…
-
Detecting FileSize – jQuery
Hey everyone, Just a quick post on how to detect a file’s size with jQuery. I’m currently using a version of this for basic client side validation: Upload image: $(document).ready(function(){ $(‘#image-file’).bind(‘change’, function() { var fileSize = this.files && this.files.length > 0 && this.files[0].size ? this.files[0].size / 1024 / 1024 : 0; if(fileSize > 0){ $(‘body’).append(”…
-
POST http://192.168.1.3:3000 406 (Not Acceptable) – AJAX with Ruby on Rails
Just a quick post on an error I ran into today when trying to create an AJAX image upload with Ruby on Rails. When submitting an AJAX form I received the following error: POST http://192.168.1.3:3000/uploads 406 (Not Acceptable) It turns out that there is a fairly simple (and admittedly obvious) solution. Ensure that your controller…
-
Not Recognised by the ‘identify’ command – Paperclip
Just a quick post on another problem I ran into while setting up PaperClip. When attempting to submit a form WITHOUT an image I received the following error message: Assets asset /tmp/stream20120218-22611-dgnkr-0.exe is not recognized by the ‘identify’ command. Apparently the most common cause of this issue is one of two things: #1: You don’t…
-
PaperClip Issues – Ruby on Rails
I finally decided to replace all my existing code to handle images with Paperclip. I was following the screencast by Emerson Lackey, #134 Paperclip, however I ran into a couple of issues. Thankfully they were all very easily fixed, and probably wouldn’t have occurred at all if I’d simply watched the whole screencast instead of…