News - Happenings at iGeeks

October 22nd, 2003

Preview Local jpg images with out upload

I have created a Flash MX version of browsing you local HDD jpg images, As you all know Flash only supports non-progressive jpeg images, hence my Flash file only supports the same. After my post there has been few mails which proves that the most popular type (gif, jpeg, png etc) of local image can be previewed.
Yes true!
You need eigther a server side script to convert the uploaded image to non progressive image (or)
a third party tools like (swishzone etc) which convert them locally for you. One more URL which proudly shows how to upload jpg image from flash and preview them. (well I beleive I have written the Browse script inside the form, this site hides the script from the User and reveals only the flash for the user), which is a component.

Well there is a exception for my code, here was my clients requirement
1) browse local HDD and select a jpg image.
2) No uploads allowed
3) No server side scripts

The reason behind that was- They had too many users and they do want to have all the uploaded images to be at the server. So was the script made very simple.

As Navneet Nair suggested in one of his mails “security violation…”. This was the thing which provoke me @ first I thought it was not possible, My first approach was that to hardcode and access from the http://localhost/myfile.htm it did work. Well let me stop here and explain the code.

Flash Action Script setup
I have a mc called “_root.img_mc” and two other Mc’s “update_mc” contains the button called “a_btn”
after you choose the image by clicking the browse button you need to click the “_root.update_mc.a_btn.onPress” the respective function get activated to call the window’s javascript function “update()” it loads the non progressive jpg image.

The function is called at 15 frame, as the Actionscript needs to get data from the javascript, what I mean over here is that “_root.path_txt.text” need to get the value, download the downloads/vinod/fxtreme_upload.zip” title=”Preview Local Images”>source file.

Kindly note: All this seems to work only with IE 5.5+ and flash Player 7, I tried with flash player 6 it did work for me but I forget the player version, some version doesn’t seem to load the image. If you think my style of coding is primitive, feel free to make the modification and let me know where I can dowload the modified source, I beleive I might improve.

Vinod

Comments

Interesting indeed.