Save JPG JPEG PNG BMP Image Action Script 3
Well finally i got time to Bring together a sample project. Kindly Let me know about your comments if this article is being helpful in solving your problem.
Kindly do write your comments on this post. This will encourage me to write more and more articles for action script community.
I have recently been working on an online Drawing Board application. We needed to save the flash movie as an Image in JPEGEncoder, PNGEncoder and BMPEncoder. I searched internet i got a lot of help but it was all dispersed on multiple site also i needed to save the JPEG, PNG, BMP in 300 dpi through flash action script. On the internet i found 2 ways to save the flash movie to any Image format such as JPEG, PNG, BMP.
1- Use the BitmapData class in action script 2/3 and get the data in string format that is basically value of each pixel and send the data 2 PHP file on the server. PHP file would prepare the header of the required image format and save the JPEG, PNG, BMP on the server as well and than at last when JPEG, PNG, BMP is saved than prompt user to download JPEG, PNG, BMP on their PC. This method had a major flaw that when data was very large in case of Bitmap image this method becomes really slow and some time script gives error on the browser.
Such Kind of solution is available on the following link http://www.quasimondo.com/archives/000645.php
Also i have attached the files that i downloaded from that website for the ease. The problem was i had to change DPI but PHP code was not that understandable. This solution is recommendable when using action script 2, as action script 2 does not have that much support for images.
2- Now for action script 3, Ah i love Action script 3 as always coming to rescue. I found classes written in Action Script 3. I have forgot the direct links from where i downloaded those files (As there were multiple locations). In this solution all the code is in flash action script.
There are 4 major classes BitmapData, JPEGEncoder, PNGEncoder and BMPEncoder. These classes prepare the header and every thing in action script and Post the Bytes as Array to PHP webpage. Now from here there are 2 ways One is PHP just temporary save file and prompt user to save or open the file. This had problems when a flash page was called from Actions script a new window in the browser open but if there is a Pop up blocker than no save dialog use to appear, as the page that was called the Popup blocker blocks it. The solution to solve this problem is use the “_self” parameter instead of “_blank”. This again had problem with internet explorer 6, but worked well with explorer 7 and Firefox. Problem was the the session expired on IE 6 once the JPEG, PNG, BMP image is saved on the server. This cause the save method just to run once on the browser instance than every time to make it work we needed to refresh browser and that was not acceptable in our solution.
Other way around is that, save the file on the server and i used a Timer in Action script which will continuously check as the file is completely saved on the server. If file is completely saved on the server than flash Call the download function of the FileRefrence class. This function downloads the file on user desktop. Now there is our choice weather to delete the file from server or to keep it on the server as well. This method is excellent as no browser or pop up blocker problem.
I have made changes in the following classes: JPEGEncoder, PNGEncoder and BMPEncoder. I have commented the section for the DPI settings in the classes you may look at the classes provided.
To use Above files make changes in the package declaration. To adjust to your older’s hierarchy.
Following is the code Accessing the above classes and Using the FileReference class to download the file on personal computer.
<pre>
////////////////////////////////////////////////////////////////////////////
//Imports
flash.display.Stage;
import flash.display.Sprite;
import flash.display.MovieClip;
import com.adobe.images.JPGEncoder;
import com.adobe.images.BMPEncoder;
import flash.net.navigateToURL;
import flash.display.Sprite;
import flash.events.*;
import flash.net.*;
////////////////////////////////////////////////////////////////////////////
//Initialization
var serverUniqueFileName:String;
mcSavingMsg.visible=false;
//Need to change the name to your sepcified server
var serverPath:String = "./";
//var serverPath:String = "http://localhost/";
var timer:Timer;
var isDownloadProgress = false;
////////////////////////////////////////////////////////////////////////////
// Call this function On Button Save
////////////////////////////////////////////////////////////////////////////
btnSave.addEventListener(MouseEvent.CLICK, clickHandlerBtnSave);
function clickHandlerBtnSave(e:Event)
{
serverUniqueFileName=getUniqueFileName("Snapshot");
if(comboFileFormat.selectedItem.label == ".jpg")
{
createJPG(mcBg, 85, serverUniqueFileName+".jpg");
}
else
{
createBmp(mcBg,serverUniqueFileName+".bmp");
}
//Similarly Save PNG could be added into the system
}
function timerHandler(event:TimerEvent)
{
}
function timerCompleteHandler(event:Event)
{
isDownloadProgress=false;
}
var downloadURL:URLRequest;
var file:FileReference;
//////////////////////////////////////////////////////////////////////////////////////////////////////
function FileReference_download()
{
trace("file to download "+serverPath+serverUniqueFileName);
downloadURL = new URLRequest();
downloadURL.url = serverPath+serverUniqueFileName;
file = new FileReference();
configureListeners(file);
file.download(downloadURL, serverUniqueFileName+comboFileFormat.selectedItem.label);
}
function configureListeners(dispatcher:IEventDispatcher)
{
dispatcher.addEventListener(Event.SELECT, selectHandler);
dispatcher.addEventListener(Event.COMPLETE, completeHandler);
}
function getUniqueFileName(fileName:String):String
{
var date:Date = new Date();
return fileName+date.getTime();
}
function completeHandler(event:Event):void
{
mcSavingMsg.visible=false;
deleteDownLoadFile(serverUniqueFileName);
}
function selectHandler(event:Event):void {
var file:FileReference = FileReference(event.target);
trace("selectHandler: name=" + file.name + " URL=" + downloadURL.url);
}
//After file is downloaded on Desktop Call this function to delete file from the server
function deleteDownLoadFile(fileName:String)
{
var header:URLRequestHeader = new URLRequestHeader ("Content-type", "application/octet-stream");
var jpgURLRequest:URLRequest = new URLRequest (serverPath+"jpg_encoder_download.php?delname=" + fileName);
jpgURLRequest.requestHeaders.push(header);
jpgURLRequest.method = URLRequestMethod.POST;
var jpgURLLoader:URLLoader = new URLLoader();
jpgURLLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
jpgURLLoader.addEventListener( Event.COMPLETE, deleteTempServerFile );
jpgURLLoader.addEventListener( IOErrorEvent.IO_ERROR, sendIOErrorDeleteFile );
function deleteTempServerFile(evt:Event)
{
var write = evt.target.data.write;
trace ('DeleteFileWrite ' + write);
}
function sendIOErrorDeleteFile(event:Event)
{
}
jpgURLLoader.load( jpgURLRequest );
}
//Fired when URL Loading Complete
function imageUrlLoaderComplete(evt:Event)
{
var write = evt.target.data.write;
if(write=="yes")
FileReference_download();
}
function sendIOError(event:Event)
{
trace("Error occured");
}
////////////////////////////////////////////////////////////////////////////////////
// Creating JPG Image
////////////////////////////////////////////////////////////////////////////////////
function createJPG(m:MovieClip, q:Number, fileName:String="snapshot.jpg")
{
serverUniqueFileName=fileName;
var jpgSource:BitmapData = new BitmapData (m.width, m.height);
jpgSource.draw(m);
var jpgEncoder:JPGEncoder = new JPGEncoder(q);
var jpgStream:ByteArray = jpgEncoder.encode(jpgSource);
var header:URLRequestHeader = new URLRequestHeader ("Content-type", "application/octet-stream");
var jpgURLRequest:URLRequest = new URLRequest (serverPath+"jpg_encoder_download.php?name=" + fileName);
jpgURLRequest.requestHeaders.push(header);
jpgURLRequest.method = URLRequestMethod.POST;
jpgURLRequest.data = jpgStream;
var jpgURLLoader:URLLoader = new URLLoader();
jpgURLLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
jpgURLLoader.addEventListener( Event.COMPLETE, imageUrlLoaderComplete );
jpgURLLoader.addEventListener( IOErrorEvent.IO_ERROR, sendIOError );
jpgURLLoader.load( jpgURLRequest );
}
/////////////////////////////////////////////////////////////////////////////////////////
//Creating bitmap images
/////////////////////////////////////////////////////////////////////////////////////////
function createBmp(m:MovieClip,fileName:String="snapshot.bmp")
{
serverUniqueFileName=fileName;
var bmpSource:BitmapData = new BitmapData (m.width, m.height);
bmpSource.draw(m);
var bmpStream:ByteArray = BMPEncoder.encode(bmpSource);
var header:URLRequestHeader = new URLRequestHeader ("Content-type", "application/octet-stream");
var bmpURLRequest:URLRequest = new URLRequest (serverPath+"jpg_encoder_download.php?name=" + fileName);
bmpURLRequest.requestHeaders.push(header);
bmpURLRequest.method = URLRequestMethod.POST;
bmpURLRequest.data = bmpStream;
var bmpURLLoader:URLLoader = new URLLoader();
bmpURLLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
bmpURLLoader.addEventListener( Event.COMPLETE, imageUrlLoaderComplete );
bmpURLLoader.addEventListener( IOErrorEvent.IO_ERROR, sendIOError );
bmpURLLoader.load( bmpURLRequest );
}</pre>
Here Server Path will be your server location where your files reside.
PHP File to save the image on the server can be downloaded here. PHP File Version 2
For Further details on saving file through FileRefrence class you may contact me if you get stuck some where.
Well finally i got time to Bring together a sample project. Kindly Let me know about your remarks if this article is being helpful in solving your problem.
Download Sample Project : Saving Image Actionscript 3 + PHP
A running sample can be viewed at the following link
www.imaginationdev.com/actionscript-blog/samples/save-image/SaveImage.swf
Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.
Comments
Dear Admin, many thnaks for this great explanation, It has helped me a lot.
Everything is running correctly But I have one question for you as you wrote: “also i needed to save the JPEG, PNG, BMP in 300 dpi through flash action script.’
How the hell have you succeed in doing this?
All the jpg I’m saving trhough this php request are in 72 dpi even if the native file I’ve put in my Flash CS3 library are in 300 dpi.
the fact is I really need to save those files in this resolution, for printing purposes obviously.
Many thanks in advance for your help !
Romain (from France)
[Reply]
Hi
I clicked on the PHP File Version 2 and got an error message.
Regards
RL
[Reply]
Hi, About the 300 dpi .. I have mentioned that i Used Hex Editor to understand the bytes to be formated in order to change the Image DPI. I have attached the updated JPEG and BMP files and also I have posted the Sample Project for you to run. And you can see the DPI to be 300.
[Reply]
Hi, psykoleo .. Brother i have uploaded a sample project i hope this will help.
Thanks to all Your comment and support is appreciated
Bilal
[Reply]
How about just saving to a directory on the server instead of save file? where would this function be changed.
[Reply]
you will just need to update the PHP file(optional) and delete the code where it deletes the file from the server and download it to local machine … It is currrently saving the file on the server. So i guess no change has to be made in PHP its just the delete file and download code that need to be removed form flash
Thanx
[Reply]
THANK YOU !!!
[Reply]
awesome!! thanks!!
[Reply]
Awesome!! Great sample !! thanks to share this!!
[Reply]
Thanks for the posting but your php code is missing. Oh well, it still has some good hints.
[Reply]
really great and superb work indeed.
thanks GOD who took me here to solve my problem.
[Reply]
Hi
Regarding saving the image in 300 dpi…. i would like to confirm whether this is possible with AS 2.0 as well. as i am using this tutorial http://www.sephiroth.it/tutorials/flashPHP/print_screen/page002.php
but saved it to 72 dpi. Please suggest.
Thanks
[Reply]
did you got my email regarding your issue ? @ Ritesh
[Reply]
Very-very thanks to you
my problem solved
thanks again…
[Reply]
is there a way to have the external SWF’s pop-up in a totally new flash window, on top of the main (presentation) window? I don’t want the external SWF’s playing in the same window, but rather show in a new window entirely?
Thanks !
[Reply]
hi , total new flash window , you mean external to the flash that is being played ? do you want to do that on the web or on the desktop computer
Thank you
Bilal
[Reply]
Hi,
I’ve put this example on my website but it won’t work properly. The file is not downloaded to my computer.
When I try by using FLASH (local) it works. When I go online it doesn’t work.
What can I do to solve this?
Thank you
[Reply]
Hi , well if you open the fla and go to the save image code page, There will be a line
var serverPath:String = “./”;
change this to your server path like http://mydomain.com/flash/saveimage
and also change the permision of the folder in which you have placed the swf file to 777
Thank you
[Reply]
Hi. Thanks for the answer.
I did that change. The .jpg is already saved on my server but the download window is not show.
Thanks again.
[Reply]
hi, this should not be happening .. what you can do is send me the url of the flash file and let me have alook at it … also if you have made asny change in the flash mention that .. I will have a look at it
Thank you
[Reply]
Thanks for the help.
Please send me the email for me to send you the URL to view the problem.
Thank you again.
[Reply]
Hi,
Its a great article. But I have a major problem. My application written in AS2 and I have to save images from it. And as you said flash is sending bitmap data to server and its taking a long time. I wonder if there is a way to convert those encoder classes into AS2.
I am very new to ActionScript, so please help.
Thanks
[Reply]
hi , thanks for your appreciation . Flash AS2 was the old way of doing stuff … But yet as its widely used . I tried to convert the files .. but could not spend much time in doing that due to work load at my end .. You can try to convert them there are techniques available. But it would need you to understand a lot of work.
But there are other method in flash as2 to save the data and few are good .. One i remember was “www.quasimondo.com / archives / 000572 . php”
Did you tried this one
Let me know if i can help more
Thank you
Bilal
[Reply]
[...] : JPGEncoder, PNGEncoder, BMPEncoder page_revision: 1, last_edited: 1219932124|%e %b %Y, %H:%M %Z (%O ago) edittags history files [...]
Hi
How can we save PNG file on server, In your example we can save file as JPG or BMP.
Thanks
Waqar
[Reply]
hi , you can have alook inside the folders there will be a file PNGEncoder … you can use that file the same way .. as other encoder files
Thank you
[Reply]
Hi.
Wondering where you can set the dpi via a variable? I am having an issue where I need to set the dpi to an astronomical value of 600-1000dpi(printing a file to a wall sized mural).
Tried exporting an image through the flash file save as image and got the flash crash
Any ideas?
Thanks for the working files.
[Reply]
HI, as per my knowledge and idea , I dont think flash could save image of this resolution.
But i can have another look in to that. I need to know have you changed the dpi in .as files where i changed them ?
Which files are you changing and which lines are you working
YOu can also subscribe to the comments so you get notified as soon as i update this article
Thank You
[Reply]
Hi, really you have done a good job, and it helps me a lot.
very thanks for your code.
One clarification:
Is this code works if i call multiple images in the movieclip?
so that i can save all the images which loaded dynamically in a single movieclip.
Please advice….
[Reply]
What do you mean by multiple images in movieclip?
Yes you can save as many JPEGs you like by just calling the functions. But the only issue could be the internet traffic issues that you might save.
If you are trying to save all clips with in one movieclip you it will save every thing with in that movie clip ?
Thank you
[Reply]
Hi
I’m trying to upload your example onto my site, at the moment i’m running a php virtual server (MAMP PRO) to host the php file.
However if i export the movie within flash i get this error message below.
1151: A conflict exists with definition serverPath in namespace internal.
[Reply]
can you show me live where this is been show ? whats url?
[Reply]
Hey Admin
Its nice work but can you please tell me do you have similar asp.net code ?.It is very urgent for me plz
[Reply]
HI , Raj i m sorry about that i really am not in to asp.net . But what you need to do is from Flash you need to call asp.net page …. in fla file you will find that . And secondly you need to write the asp.net code similar fuctionality to php code .. If you can see the php file its doing .. 1- saving the bytes tat are passed on to a temporary location on the server and secondly there is a fucntion that flash calls to check weather the uploading has been done or not … I guess some body knowing ASP.net can do that
I would like All Readers of this Blog If any one could send me ASP.net solution to upload on this BLog will save my time and Will be great help for action script society
Regards
Admin
[Reply]
I have a strange request…
I want to keep the image the size I made it in inches, but have it at 300 dpi. Currently, when it makes it 300 dpi, it just reduces the inches. I’d like the width and height to stay the same as what is on the flash stage, but have it create it at 300 dpi. The jpeg image is large enough and it has additional text, all which saves just fine. It just saves it at 1/4 of the size I need.
Any ideas? I tried making the m.width and m.height twice the size, but that just added a bunch of white space. It didn’t increase the image at all.
[Reply]
Hi all,
Can i have the asp server script for the same because i am facing the same problem but my working environment is ASP
Please Help me!!!!!!!!!!
[Reply]
please send me code for asp.net c#
[Reply]
Hi! First of all thanks for this great tool! Is it possible to have the code in AS2? what should I change to make it work in flash8? I’m on the very end of a as2 driven project, and I need this badly. Thanks for your help in advance!
[Reply]
thanks again!
[Reply]
HI, all .. stressed days …. Sorry for late replies
well first
Mr lizardboi : No we cannt do this in Flash 8 i have tried playing around .. but it wont work for flash 8 we have other solutions available on the internet.
saving a jPG in Flash 8 is easy .. We use the php image manipulation to save the JPG . we just pass bytes to the php file
if you dont find that let me know i will provide you the link to the site
Thanks
[Reply]
Man Sorry i could not write up the asp code as i m not an ASP programmer
Well all you need to do is call asp file from flash.
In your asp file replicate the algo that i have used in the PHP file can you do that
Let me know if i can be of further help
Bill
[Reply]
hi Kevin there is another article that i plan to write is to save image as custom height and width ..
For time being i have uploaded it on my server and here is the sample
http://actionscript-blog.imaginationdev.com/samples/save-image-enhanced/saveimage.zip
Also this Article will never be dead :>
Keep Supporting
Bill
[Reply]
Great tool!!!! THANK YOU!! …just need to get it working….
Tried uploading to my server, but no file is returned..it asks where to save…and just sits.
[Reply]
Another feature that was great with sephiroth.it as2 version of an image saver was the ability to clip your output to a limited width and height from the top right hand corner. How could this be done with your code?
[Reply]
This is the error I get …
file to download ./Snapshot1227722530464.jpg
selectHandler: name=Snapshot1227722530464.jpg.jpg URL=./Snapshot1227722530464.jpg
Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
at Error$/throwError()
at flash.net::URLVariables/decode()
at flash.net::URLVariables()
at flash.net::URLLoader/onComplete()
[Reply]
This seem to get things working…
in the php file … change:
$returnString = http_build_query($returnVars);
to:
$returnString = http_build_query($returnVars, ”, ‘&’);
How about that trim feature..?? :o)
[Reply]
To trim you have to do that in flash … in Create JPG method in flash … check the paramters for the BitmapData.draw() functions. This has Clip Rect feature
Regards
Bill
[Reply]
Hello, I have a few comments, followed by a request for help with expanding the use of this tutorial.
Comments:
1) This is an excellent tutorial and unlike many that I find online, actually works in spite of its complicated operations. Thank you!
2) I experience the same error as Chris above, however his PHP fix did not work for me. However, everything works 100% as it should in spite of the error. I read somewhere that the error will always be thrown when testing from a local machine, but obviously it does not show when running from a server.
Questions:
I am looking to expand the use of this tutorial to include one or more of the following:
A) Instead of downloading the image to the user’s computer, is there a way to email it from the server to an email address? For example, the file uploads to the server as usual, then is automatically emailed to a certain address and deleted from the server afterwards.
B) Instead of downloading images one by one, is there a way to save a number of the users’ photos to the server, keep track of them (array?), and then download them all at one time? For example, maybe a user wants to download every 10 images he or she saves, instead of each one individually.
C) A combination of A and B. For example, the user sends 10 photos to the server and then clicks a button to send them all to the email address. In this case and B, it would be especially nice if there were a way to create a .zip file since multiple images are being handled.
In all cases, a PHP and/or AS3 solution is perfectly fine. I know I am asking a lot, but this might be an opportunity to expand an excellent tutorial. Any assistance will be appreciated.
[Reply]
Sure i will look in to it as i m not a php guy my self. see if i can get some help .. or any one could send me code for this
to support me also
Thanks
Billy
[Reply]
For anyone who might be watching, maybe it will help to break down the specific tasks involved in my questions:
*Making PHP/AS remember what images it has stored on the server during a given session, so it can download/email them at one time (i.e. we need to store the image name - snapshot1231233313.jpg - for all of the images that the user sends until they are emailed/downloaded later)
*Emailing server files as an attachment using PHP.
*Downloading multiple server files to Flash at once (i.e. a single save dialogue box to save all images instead of one each time an image is encoded)
*Creating a zip of the server files, so they can be emailed/downloaded as a single attachment.
*Deleting all of the related server files after they are emailed/downloaded
Example implementation: Imagine a Flash paint program. A user could draw many pictures and each one would be sent to the server upon completion without interrupting him (completion would be triggered by an event, button, etc). When the user is ready to quit painting altogether, he can choose to download all of his images from the server and/or send them all to a server predefined email address.
Alternative Implementation: All of the images for all users automatically get saved to the server. At a certain time (i.e. once per day), all of the images are automatically sent to a certain email address or downloaded to a certain location. This would be less desirable, since server space would be at risk of overloading for 24 hours instead of a single user’s session and users would have to wait longer to access their files.
[Reply]
great example. i appricitate your tutorial on this.
the example im using is the latest u posted, with image size fields
i cant seem to have anyone with the error like mine.
i uploaded the file to server, & changed permissions to 777.so bingo, it runs and creates the image, i can see when i ftp the server, but it doesnt pass on for file to be downloaded. i tried ie, ff & chrome, all same results. could this version of server php error?
also is mcSavingMsg textfield suppost to be working? it seems turnoff from your code
seems like the :
file.download(downloadURL, serverUniqueFileName+comboFileFormat.selectedItem.label);
is not triggering
hope you can help
ss
[Reply]
hi,
i tried downloading the files from ur link.but its not downloading.can u give me the php file content also in this post so that there will be no need to download any file .
it will be helpful if u can give me the link for the source files in another server .i think its the problem with your server
cheers
venkat
[Reply]
Hi, try downloading files now .. there was a problem with the server … i guess but every thing is working fine now .. Action Script 3 is the best
[Reply]
I tried to use your PNGEncoder class, but the image is still in low resolution.
I tried also to use your BMPEncoder class, but I cannot open the image (photoshop says it cannot recognize a newline character).
Do you have any suggestion ? I really need to take high resolution screenshot.
Thnakyou very much
Andrea
[Reply]
Hi Atari :
try using this link
http://actionscript-blog.imaginationdev.com/samples/save-image-enhanced/saveimage.zip
Thanks
[Reply]
Just want to say thank you for sharing this ![]()
[Reply]
hey, love your work, and thanks in advance
i’m having a newbie problem,
when i click save image, it just says “waiting for lebaxxx.com…” and never prompts me to save to the desktop, however it does save a file to the server, making me think i havnt specified somthing right…
i’m sure its somthing stupid so please help!…
I have specified my server path as such
var serverPath:String = “http://www.lebaxxx.com/test/saveImage/”
the folder permissions are 777
is there somthing i’ve forgotten to do?
see example here
http://lebaxxx.com/test/saveImage/
[Reply]
Hi,
This is great - I’ve got it up and running with my own graphics and it works perfectly. HOWEVER, I’d like the option to save as a PNG. How do I do this?
createPng(mcMovie,serverUniqueFileName+”.png”) —> evidently NOT an option.
Thanks!
Jennifer
[Reply]
Hey ! thx for your tutorials and files, it help me a lot! Now the only problem I have is that my snapshot is saving on the server but didn’t ask me if I want to save it on my desktop. Is it normal?
[Reply]
hi,
wondering if you know of a quick way to save the images locally (i will be using this in a mobile urban projection context, and may not have wireless access at the given time/location, so want to circumvent the server communication…)
thanks
AS
[Reply]
hi,
wondering if you know of a quick way to save the images locally (i will be using this in a mobile urban projection context, and may not have wireless access at the given time/location, so want to circumvent the server communication…)
thanks
AS
grl
[Reply]
Getting an error in Flash Player 10 when running your live demo saying:
Error: Error #2176: Certain actions, such as those that display a pop-up window, may only be invoked upon user interaction, for example by a mouse click or button press.
at flash.net::FileReference/download()
at SaveImage_fla::MainTimeline/FileReference_download()
at SaveImage_fla::MainTimeline/imageUrlLoaderComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
Any ideas?
[Reply]
Hi Matt, First of all excume me Guys for slow reply. Just got busy in the Job. Well first Matt the PHP code you have to alter that.
If you read above comments one of the guys has posted a solution for this one.
Flash is fine you need to adjust PHP.. I am not personally that good in PHP my self.
So if some body cold send me a solution for the php file that will help all readers and i will upload the new PHP file in the sample at my side as well.
Thank you
[Reply]
Hi Agent Scott , Install apache server on your machine and deploy application on your local machine than it should save the image at your local machine as well.
Thanks for waiting for reply.. I get so busy some times.
[Reply]
Hi Daniel, this should not be a problem. You have to check the Browsers permisions and access for scripts. That might be blocking the popup download box.
Thanks
[Reply]
This is great. Thanks.
One issue though it that it seems to take quite a long time where it says “transferring data to server”.
What is taking so long?
If you redirect the browser while this is happening does the file still transfer to server?
Thanks again!
Steve
[Reply]
Hi, its verry nice but your sample not work in flashplayer 10. Like says Daniel:
Error: Error #2176: Certain actions, such as those that display a pop-up window, may only be invoked upon user interaction, for example by a mouse click or button press.
at flash.net::FileReference/download()
at SaveImage_fla::MainTimeline/FileReference_download()
at SaveImage_fla::MainTimeline/imageUrlLoaderComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
I cant find any permisions in my browser (Firefox) for this.
[Reply]
I have the same problem as Roberto had in August of last year. I’ve changed my server path to point to my server in the Flash file. I’m wondering if this problem was ever solved. Below you will find the description of the problem.Thanks in advance for your help.
Hi,
I’ve put this example on my website but it won’t work properly. The file is not downloaded to my computer.
When I try by using FLASH (local) it works. When I go online it doesn’t work.
What can I do to solve this?
Thank you
[Reply]
Hi, I love your script and it has really helped me!
I was wondering how to save multiple movieclips. For example, a dog image as one movieclip and a collar as another movieclip.
I’m new to flash and actionscript. ![]()
[Reply]
Hi, thanks for the script! It was very useful, but I have a problem. I need save an Letter Image size to print after. So I need that the image could be 1240×1754px by 150dpi (not 300), in which lines I must change it?
Thank you very much!
Frank
[Reply]
Hi
i am uploading the mulitple images using these code but i want to check the image dpi before sending the content to the server if that image is less than 160 dpi then that image will not be sent to the server other wise that image is uploaded to the server is there any way to do it please tell me
[Reply]
[...] libraries to encode the image as a binary data. (if you want to read more on image encoding, refer here) request.contentType = "application/octet-stream"; request.data = ba; request.method = [...]
Hi!
I have a very big or strange problem, I don’t know, all the posts say that it works great or that they have some sort of error but my problem is this, I click the save button and nothing happens, the folder is located in mi localhost, so I instantly thought that it had something to do with my server so I went to your running sample and it’s the same thing, nothing happens.
I checked this in both ie and firefox and in the this one in the status bar it says transferring data from http://www.imaginadiondev.com….. but it stays like that for as long as I keep the window open I don’t even get an error to work with.
Is there something I’m missing or what could be the cause of this?
Thank you very much.
[Reply]
Hi, when i try it i’ve got a problem in the output tab of flash:
Error during opening URL ‘http://www.mysite.com/jpg_encoder_download.php?name=Snapshot1253096031663.jpg’
what’s my fault?
tnx ^^
Ps the folder on the server have all possible permission
[Reply]
Hi
i need flash and swf whith a button for save swf to image in my pc
can u help me ?
thanks .
[Reply]
Hello,
Thanks for this wonderful article.It is the most helpful article over the net.Im unable to store the file in server or download.It just says transferring data and stands halted.I have changed the permission of the folder to 777 and also updated the server path in fla file.
Can you please help immediately.
[Reply]
I downloaded the scripts from second link where you have provided in the discussion.Thanks a ton.!!It is really a Best working solution.
[Reply]
When I am trying to paste the below code to my another script
import flash.display.Stage;
import flash.display.Sprite;
import flash.display.MovieClip;
import com.adobe.images.JPGEncoder;
import com.adobe.images.BMPEncoder;
import com.senocular.display.duplicateDisplayObject;
import flash.net.navigateToURL;
import flash.display.Sprite;
import flash.events.*;
import flash.net.*;
It throws syntax error.I have not added anything still.Just copy paste of these scripts is throwing syntax error.
Can you please help
[Reply]
Hi
This is an great example of flash to jpeg export to a server. I have one question, however. I would like to save 300 dpi jpeg images. I saw some of the earlier comments, and I did see where the BMPencoder.as files was changed to allow for 300*300 dpi. However, I can’t ind the same change in the JPGencoder.as file. Would you please show me where those changes are?
Also, what version was the flash program written in? I am trying to open the file in Flash 8 pro and I get an error about an unexpected file format.
Thanks for your excellent example and any help you can give .
[Reply]
amazing work, thank you for sharing this!
i’ve run into an issue that seems to come up without resultion here - basically, the server saves the image (so i know that the server path is correct) but i never see the dialog window for saving the file to desktop.
i’ve been messing around for the past few hrs, and when i went to try out the demo i noticed it doesn’t work either! i’m on a mac, tested in ff3, chrome and safari, all without luck.
i was hoping that you may have an idea on what could be causing this. any help would be greatly appreciated. thanks, and keep up the awesome work!
[Reply]
in this i tried out to save the image as PNG using png encoder but the image background is not a transparent one
[Reply]
thank you!
[Reply]
sendToURL(new URLRequest(jpg_encoder_download.php+”?del=jpg_encoder_download.php”));
you need to validate the data in your php.
$filename = $_GET["del"];
if (substr($filename, strlen($filename) - 4, strlen($filename)) != “.jpg”) die();
[Reply]
The author has very much tried. I support the majority of commentators
[Reply]
Hello, I made a Drawing Application and I’ve been looking to a way for users to save their drawings as a jpg onto their computers.
Could anyone give me a hint or perhaps someone that might be interested developing the code for me.
Thank you very much,
Pedro.
[Reply]
hi,
i m a MCA six semester student,i m doing my project in PHP.
In my project i need to capture image from the web cam and save the image in to the backend database….
i m trying to find the script in the internet but could not get it…
Please guide me to do it….
Hoping to get a positive response from u……
thanks…………..
[Reply]
Hi,
why doesn’t the example work?
I downloaded it anyway, but it doesn’t work, it stays just like “Transfering data from http://www.imaginationdev.com...”
but nothing…
wich is the problem?
thanks a lot.
[Reply]
hi all!
is it possibile to save the image in my pc?
can u help me ?
[Reply]
Hy,
I found your blog very helpful.
I need some help though, I have made a paint application, and I want to incorporate networking in it, so that two people can share a common canvas and draw in real time. Can you please help me with this??
I was thinking that I will save one image at server, and will keep on updating that image in every small interval, and the two clients will keep on fetching the same image from the server in small interval, but it seems that the application will be very slow if based on this approach.
Please help.
Thanx
[Reply]
I get an error when running in flash player 10:
Error #2176: Certain actions, such as those that display a pop-up window, may only be invoked upon user interaction, for example by a mouse click or button press.
at flash.net::FileReference/download()
at ……………………
It saves the image anyway, but an error is never good.
Any why to get around it?
[Reply]
@Petter: Well, like the error states, its only allowed to be invoked upon user interaction, in plain english: its only allowed when activated trough a button -> aka, make a button to initialize the download, and the error should be gone.
@Admin: i know its like 2 years late, but the classes come from ‘AS3CoreLib’, wich nowadays is available on google code here: http://code.google.com/p/as3corelib/source/browse/#svn/trunk/src/com/adobe/images
The BMPEncoder seems to have been dropped, but is still available from ‘Canvas3′ http://code.google.com/p/canvas3/source/browse/trunk/source/code/com/adobe/images/
[Reply]
Hi,
I want to take snapshot of movie clip..There may be some objects will be placed on top of movie clip..Still that snapshot would capture anything on that movie clip..
Actually write a code to save a movie clip as image which saves contents(only childs of movie clip) of movie clip.. But i want it to save as anything has seen on movie clip must be saved as image..
Do u have any pointers regarding that?
Thanks in advance,
syaam
[Reply]
Thank you so much !! that’s simply fantastic!!
[Reply]
i have call images as like xml file in flash 8
[Reply]

i am gonna show this to my friend, bro
[Reply]
Lean Reply:
November 21st, 2009 at 2:31 pm
I also click php file version 2 and it display, “an error occured2″
[Reply]