James,

Using RemoteObject I've uploaded bitmap snapshots without previously saving the 
bytes to disk, using CF as a backend.  Not exactly sure how you'd do this with 
PHP, but I'm sure it's doable. You'd probably have to use some version of 
AMFPHP. 

Jeff

-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of James
Sent: Friday, April 16, 2010 1:40 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Uploading An Image Without Browse

Cheers Jeff. I'm sure that'd work too. I've found a way around it and can now 
allow users to upload without the browse. The problem is though I now want it 
to upload the file without it having to save it on the user's machine first. At 
the moment my code snapshots the html component, saves this as a bitmapdata, 
resizes this bitmapdata, then a jpegencoder turns this bitmapdata into a jpg 
file which is named after whatever the user has entered into a text input 
component in my app. It then uploads this jpeg from the location it's saved to. 
I'm wondering is there any way of me editing my code so it uploads the jpeg 
straight away rather than storing it on the machine too? Here's my script code 
containing the function which does all this:-

<mx:Script>
        <![CDATA[

                import mx.graphics.codec.JPEGEncoder;
                import mx.graphics.ImageSnapshot;
                private var imageuploadurlRequest:URLRequest;
                private var serverSideScript:String = "*my upload php file goes 
here*"; 
        
                private function imageuploadinit():void {
                        imageuploadurlRequest = new 
URLRequest(serverSideScript);
                }
            
                private function takeSnapshot(event:Event) :void{
                    var bigbmd:BitmapData = 
ImageSnapshot.captureBitmapData(linkviewer) ;            
                        var scale:Number = 0.50; 
                        var matrix:Matrix = new Matrix(); 
                        matrix.scale(scale, scale);
                        var smallbmd:BitmapData = new BitmapData(bigbmd.width * 
scale, bigbmd.height * scale, true, 0x000000);
                        smallbmd.draw(bigbmd, matrix, null, null, null, true);  
                        
            var jpgEncoder:JPEGEncoder = new JPEGEncoder( 100 );
            var ba:ByteArray = jpgEncoder.encode(smallbmd);
            var enteredimagename:String = titleentry.text;                      
  
            var file:File = 
File.applicationDirectory.resolvePath(('assets/createdimages/')+enteredimagename+('.jpg'));
            var wr:File = new File(file.nativePath);
            var stream:FileStream = new FileStream();
            stream.open( wr, FileMode.WRITE);
            stream.writeBytes ( ba, 0, ba.length );
            stream.close();
            
imagesnapshotpreview.source=(('assets/createdimages/')+enteredimagename+('.jpg'));
                file.upload(imageuploadurlRequest);                             
                }
                                                                        
        ]]>
</mx:Script>

--- In flexcoders@yahoogroups.com, "Battershall, Jeff" <jeff.battersh...@...> 
wrote:
>
> Using the FileSystem API and ByteArray you can save/read/upload images 
> automatically, using your middleware of choice without the user having to 
> browse and select the image. 
> 
> Jeff
> 
> -----Original Message-----
> From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On 
> Behalf Of James
> Sent: Thursday, April 15, 2010 3:29 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Re: Uploading An Image Without Browse
> 
> My app has a html component which allows the user to enter a website into it. 
> When the website is fully loaded a snapshot is made of the html component and 
> then saved in the application directory automatically. I want this file to 
> then automatically upload to my server rather than just being saved on in the 
> app directory. I can easily do it using the browse method but can't figure 
> out how to get it to simply go straight to the server without the user having 
> to save it somewhere and then browse to upload it if that makes sense..
> 
> --- In flexcoders@yahoogroups.com, Steve Mathews <happydog@> wrote:
> >
> > When you say "take a snapshot", what do you mean?
> > 
> > On Thu, Apr 15, 2010 at 10:52 AM, James <garymoorcroft_ict@>wrote:
> > 
> > > Is there any way to let a user upload an image from an air app without
> > > having them browse for it? I want to let my users enter their name into a
> > > text input, take a snapshot and then the image will be uploaded to my 
> > > server
> > > as whatevernametheuserhasentered.jpg
> > >
> > > Is there any way to do this and does anyone know of any similar examples?
> > > All I can find is uploading via the browse function.
> > >
> > >
> > >
> > > ------------------------------------
> > >
> > > --
> > > Flexcoders Mailing List
> > > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > > Alternative FAQ location:
> > > https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
> > > Search Archives:
> > > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
> > > Links
> > >
> > >
> > >
> > >
> >
> 
> 
> 
> 
> ------------------------------------
> 
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Alternative FAQ location: 
> https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
> Search Archives: 
> http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links
>




------------------------------------

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Alternative FAQ location: 
https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! 
Groups Links



Reply via email to