0

Has anybody found a way to limit the size of photos uploaded through iOS? Using a standard file input field results in massive images (like 2448x3264 and at least a couple mb) which take quite a while to upload, especially if you have a poor connection.

I found a couple tutorials about how to take an image from a file input and resize it with canvas, but I'm not sure that's going to work for my situation.

Community
  • 1
  • 1
Andrew Philpott
  • 939
  • 1
  • 10
  • 11
  • 1
    You can only check the image size on the server as far as I know. What language are you using on the server? – woz Nov 14 '12 at 19:10
  • @woz Javascript does allow you to get contents of a file such as mime type, size etc. – Marko Nov 14 '12 at 19:42
  • This is for a web app that's built on ExpressionEngine. I'm using the File API to resize images with canvas, but I'm not sure that's going to work for me because it just gives me base64 data which I don't think EE will accept. – Andrew Philpott Nov 14 '12 at 19:47

1 Answers1

1

UPDATE

I have just realized that Safari on iOS supports the HTML5 File API.

You can use this for your purpose and much more.

Here's an excellent article on how to implement this functionality.


If you're talking about uploading to a web page, you maybe able to get the size via Javascript.

Please note that this hasn't been tested.

Input element

<input type="file" id="uploadPhoto" onchange="checkSize(this)" />

Javascript

checkSize(el) {
    alert(el.files[0].size);
}
Marko
  • 71,361
  • 28
  • 124
  • 158