MyBB Community Forums

Full Version: Adding the 'accept' attribute to the attachment upload box
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
[attachment=44758]

As it currently stands, I'm prompted with Camera, Documents, Camcorder and Voice Recorder on my version of Android when tapping the drag-and-drop box. Needless to say, this is a problem. In order to share my screenshot, I had to open the image, email it to myself, open it on my desktop and upload it. I could not navigate to the screenshot on the Android device itself because the file system or Gallery weren't options. This is something I fixed on earlier versions of MyBB, before the drag/drop box was a thing, by specifying an accept attribute for the browse button/input, like below:

<td class="trow1"><strong>New Attachments (up to 40 files):</strong> <input type="file" name="attachments[]" accept="image/*" size="30" class="fileupload" multiple="multiple" />

It looks like I'll need to edit post.js within the /jscripts/ folder. Can someone tell me where and how to attach this attribute to theĀ "Click or drop some files here to upload" box? This is what I found within post.js:

Post.fileInput = $("input[name='attachments[]']");

That's on line 4. What should I add to set the input to accept only images? An addition like this should fix the Android issue (showing Documents or Camcorder instead of giving me an option to browse the Gallery or file system as a whole).
Sorry if this is convoluted. This is what I'm referring to:

https://stackoverflow.com/questions/2447...on-android

I'm not a coder and I'm not sure where or how to insert accept="image/*" within jscripts/post.js. That seems to be the file that requires an edit. It's responsible for the dropbox uploader.
You'd need to edit the post_attachments_new template and add the attribute to the file field.

That\s a very strange Android bug though, you shouldn't need to restrict the forum to only allow image uploads purely because of Android. Quite surprised that's how Android handles file upload fields to be honest.
Thanks for the help Matt -- that solved it. I was looking at the wrong template. And yeah, Android handles it poorly.