How to display local image using Flash? - javascript

Suppose that, I have local image path that get from <input type="file"... web control using javascript.
I want to pass this path to Flash object and display that image in it.

I believe what you are looking for info on is FlashVars.
Flash Vars are ways to pass data to swf files. Very similar to Query Strings.
They size limit is 64k and are support on Flash Player 6 and newer I believe.
Here is the adobe site on them.
I hope this helps some

Related

how to read text from input file in javascript?

I have a text file i want to read in my html page,both are in the same directory and i am not running a server. I intend that my users use the script offline(basically text manipulation based on expressions and preserving new line characters) .
I tried ajax call but mostly cross domain origin problem occured and i know most of the users will have this security tighened up in many browsers , so its not of use to circumvent this in only in my browser.
I want to support many browsers including old browsers as in IE7,8 etc which do not support HTML5 filereader.for the same reason reading using filesystemobject or activex is not good.
Reading the file after user select it as input , is this possible?Otherwise i would have no option then using other technologies like php,java etc which may expect my user to setup these.
Please excuse me if i am repeating this but i am a beginner web developer. I know that reading local files via javascript is not possible but is there any other way?
If you can't support FileReader, then the answer is pretty much no (at least, if you want to support a large range of browsers rather than rely on convenient feature x of browser y). Unless : you indeed increase the requirements for running the application and get some sort of local server going (for instance node.js, Apache, TomCat, etc. but like you said this will greatly increase the requirements and become cumbersome for users).
You could also rethink what it is you're trying to achieve. What are the contents of the file you want to read ? Can't these contents be part of the HTML file you're serving to your users (i.e. a large JSON Object inside a script-tag ?)
On possibility of using node.js:
Node.js is quite easy to install and assuming you are requiring from your users to install it, you can use it as a local server, which is a nodejs script of about two lines in size :). Running it locally would also omit the need to upload anything anywhere as you can directly read from the file system using the fs-object (see sitepoint.com/accessing-the-file-system-in-node-js).
STILL: from both a design and ease-of-use-point of view you might want to resort to using either another technology, or include the text file content inside the HMTL file

How to resize images on server-side

I’m writing webpage that will display hundreds of pictures. Problem is size of image(+-5MB). This images are background-image of div. I use JS for changing this background-image.(sometimes 1 per sec.) Is there any way how to shrink those images or how to speed up loading? (I can't modify this images by Photoshop or another similar SW. I must use the original.)
What do you mean you must use the original if you wish to shrink the images? In my opinion the file size is not suitable for a web application and you must decrease the file size of these. If you have access to a server side technology like PHP or ASP.NET you can modify the images before displaying them using libraries like ImageMagick (http://php.net/manual/en/book.imagick.php) or ASP.NET Sprite and Image Optimization Library (see http://www.hanselman.com/blog/NuGetPackageOfTheWeek1ASPNETSpriteAndImageOptimization.aspx) but these will use resources to process and thus your site will still have an performance overhead.
I advise you to modify your images using a tool and don't have the server or browser modify these. If you don't have access to a tool like Photoshop or GIMP you can use online tools to create reduced versions of your originals like Yahoo's smush.it - http://www.smushit.com/ysmush.it/
Not the best answer but I hope it helps.

How to get the associated icon of a file in HTA (HTML/Javascript/VBScript)

I'm building an HTA application in which I need to display a list of file with their associated system icon.
I'm using FileSystemObject to list the file but there seem to have no way to get the icon...
I've found a script in VBS that can save the icon of a file into a .ico .
It read the file (PE resource file, .exe or dll) and parse the icon data.
I modified that script to return the icon's bytes, convert it to base64 and use embed base64 images in HTML.
Here's the original script: http://gilpin.us/IconSiphon/
Issue
) In most case the .ico contains multiple icons (many sizes and color depth) but there's no way I can specify which one to use (as I need 16x16 icons).
) Not all icons are displayed
) Could be slow with many file as it read exe and dll (but I'm ok with that, I can cache already fetched icon)
I've also tried some ActiveX control but none seem to work properly. Even those provided by microsoft (ShellFolderView or ListView) are very buggy.
Requirements
Must display 16x16 icon
Must allow multiple file selection
Everything must be embed in hta (if possible). No external .exe
Does anyone know a way to achieve that?
Thanks!
Use SHGetFileInfo() with the SHGFI_ICON flag.
http://msdn.microsoft.com/en-us/library/windows/desktop/bb762179(v=vs.85).aspx
The filesystemobject will provide you the necessary functions for enumerating files on the local filesystem. However to get the icon image you will need to use the win32 api per #seanchase's response or an external exe.
However you can access the win32api via javascript in the hta using the wshApiToolkit activex object - http://www.google.com/search?q=wshAPIToolkit.ucATO%2F&rls=com.microsoft:en-us&ie=UTF-8&oe=UTF-8&startIndex=&startPage=1
Find a copy of that and you're close to being done. It does require distributing the activex object with your code and shell executing the registration process from within the HTA so that might violate your third constraint. Though I believe you can base64 encode the exe into the hta in a dataurl and write that back out to the file system so it would at least be bundled into a single file. If you support that option then maybe embedding an exe that does the same would meet your requriements.
Definitely some hacky stuff that may be unstable on future OS versions - heck I'm not even sure the wshApiToolkit works on windows 7, and 8 is just around the corner. Good luck!
You indicated you're opened to installing ActiveX components and using them in your HTA.
If I had the time, I would approach this for myself by creating ActiveX components using Visual Studio to call FindResource, LoadResource and LockResource. These will enable access to the Group Icon resource for which I would then provide rich interfaces to iterate through the Icons offering the ability to extract BMPs (or PNGs).
This is "how" I would go about achieving this short of actually going off doing it.
Once I build a similar HTA interface and I faced the same problem. I solved the problem by creating a custom icon gallery and converting the images using base64. You may achieve the same by either converting or using sprite. Many UI does it, even java.swing has its own collection embbebed. As you noticed, reading from *.dll can speed down the application

Security considerations when using canvas in conjunction with file uploading

I'm working on a image editor/uploader based around Pixastic where I grab image data out of an <input> tag, put it into a canvas, and after manipulating it, encode the data in base 64 and post it to my app with javascript, where it will be saved as a new image file. If it were a standard file upload, I would give the file a new (safe) name, test to make sure it was really an image file and copy it to strip any potentially malicious/personal EXIF data before making it available to users.
My question is - do those security measures make sense in the canvas situation, or are they pointless? Additionally, are there any security issues with my approach that I'm overlooking?
Fyi: the serverside decoding/etc will be done with php.
Thanks.
Some of what you have asked (Not sure if all) are discussed by Shiflett Here
Check it and comment what you think of it!

Set Image Src to Local File

I am writing a Firefox extension and would like the users to be able to change an image on a web page with a local image. Is it possible, using JavaScript, to change the image source with an image that is saved on the user's local machine?
Let me know if you need more information. Thanks
You can set SRC of an image to a "file://" URI obviously, or any string for that matter. But getting the path may prove more tricky - you'll have to use browser's internals to grab the path.
Of course this is completely impossible from a webpage javascript, but an extension is in a much weaker sandbox than a page, and you can do quite a bit about the filesystem, so answers that suggest it's impossible are plain wrong.
I think this hacks post has some useful information on recent HTML5 feature work to support access to local files:
http://hacks.mozilla.org/2010/02/an-html5-offline-image-editor-and-uploader-application/
I'm not sure about using local files as images directly, but at worst, using the techniques demonstrated there, you could create a data: URL to use instead.
JavaScript cannot access the local filesystem for security purposes. Your plug-in will have to work-around this problem.

Categories

Resources