0

I have a file upload html control on my form like this:

<form id="myForm" action="FormReceiver.php" method="post" enctype="multipart/form-data">
    <input type="file" name="foto" id="foto"  />
</form>

Is there anyway, I can resize this image before sending it to server and then after receiving on server can i resize it again to origional size?

Actually the users of my site will browsing this page on mobile, so it takes very long to upload images on mobile device.

icodebuster
  • 8,890
  • 7
  • 62
  • 65
Azeem
  • 2,904
  • 18
  • 54
  • 89
  • what you could do is resize before displaying , and storing the original full resolution image with a data attribute or hidden input element and receive it on php......resizing from low res to high is not same as high to low . The Quality is lost ... – mega-crazy Aug 04 '13 at 13:39
  • Actually, I only need to store this image to DB. No need to display it on page. How can i resize before sending it to server? I think some JS will do this job. any ideas?? – Azeem Aug 04 '13 at 13:44
  • Use the [GD-library](http://php.net/manual/en/book.image.php). – ShuklaSannidhya Aug 04 '13 at 13:46
  • @NidaSulheri If you Find The Answer is correct then accept it, since it would be removed from unanswered list of questions. – Ayush Oct 07 '13 at 08:50

2 Answers2

3

You can use HTML5 to resize and then upload Have a look at this article link.

HTML5: Image resizing is only possible on Firefox 3.5+ and only at a fixed quality. WebKit/Opera doesn't support direct data access to the selected files.

The rest it handles with Flash.

Ayush
  • 3,989
  • 1
  • 26
  • 34
-2

you can resize it with GD which is built in with php.

After it has uploaded to tmp file, resize it and save it to your desired place.

Anonymous
  • 1,405
  • 4
  • 17
  • 26
  • 3
    The OP wants to resize before uploading, i.e. client side. GD won't be of any help for that. – m90 Aug 04 '13 at 13:52