Re: Memory limit of 8 MB not enough
| From: | tedd | Date: | Wed, 16 Apr 2008 15:45:19 +0000 |
| Subject: | Re: Memory limit of 8 MB not enough | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-273088@lists.php.net to get a copy of this message | ||
At 10:53 AM -0400 4/16/08, Andrew Ballard wrote:
On Wed, Apr 16, 2008 at 9:59 AM, tedd <tedd.sperling@gmail.com> wrote: I saw one the other day that caught my eye -- will look into it.Andrew: I think you are right -- I wasn't able to resize the image. Here's the link that caught my eye, but it doesn't work as described: http://javascript.internet.com/forms/image-upload-preview.html Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.comThe first problem I see implementing the approach is the JavaScript sandbox. JavaScript is allowed to read the text of the input file field (and thus know the file name and path once a file has been selected); it cannot access the disk to actually get to the image or do anything with it. From here, I'm thinking there are a couple things you could do with JavaScript. The first would be to embed the image into the web page using an IMG tag, which would allow you to determine the pixel dimensions (but not the actual file size). The second would be what Gmail seems to do, and actually upload the form to their server with some sort of AJAX request, at which time your server could return information on the size of the file. However, if the file is too large, you're back to the original problem of needing to increase the RAM limit in PHP. The second problem is, as I said, I'm not aware of any JavaScript that can manipulate the image. JavaScript can cause the display of an image to be resized within the browser, but that doesn't actually affect the stored file. I don't know, but I guess if you could actually get to the bits, you could probably write an algorithm in JavaScript to resize an image by manipulating the bits, but I think it would be dreadfully slow if it would even run without running out of resources. I think the only pure-client options are either Java (which would require special permissions to get out of its own sandbox) or ActiveX. If you know of some other approach, I'd be interested to see how it works. Andrew