Displaying an image in flex

How to browse an image from my local disk and display it in a
text area in flex

i have writen the code for the uploading of images,the images
first get displayed in the text area and then after clicking the
"button" to display the images in the tile list component but
somehow the tile list takes the path of the image rather than the
actual image....plz help
mxml code
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
creationComplete="init();" initialize="initData();" width="100%"
height="100%">
<mx:HTTPService id="userRequest" url="
http://localhost/mixbook/return.php"
useProxy="false" method="POST">
<mx:request xmlns="">
</mx:request>
</mx:HTTPService>
<mx:Script>
<![CDATA[
import mx.controls.Image;
import mx.collections.ArrayCollection;
private var urlRequest:URLRequest;
private var fileReferenceList:FileReferenceList;
private var serverSideScript:String = "
http://localhost/mixbook/upload_image.php";
[Bindable]
public var TileListdp:ArrayCollection;
private var myArray:Array = new Array;
import mx.collections.ArrayCollection;
import mx.controls.TileList;
private function init():void
urlRequest = new URLRequest(serverSideScript);
fileReferenceList = new FileReferenceList();
fileReferenceList.addEventListener(Event.SELECT,
fileSelectedHandler);
private function uploadFile():void
fileReferenceList.browse();
private function fileSelectedHandler(event:Event):void
var fileReference:FileReference;
var fileReferenceList:FileReferenceList =
FileReferenceList(event.target);
var fileList:Array = fileReferenceList.fileList;
// get the first file that the user chose
fileReference = FileReference(fileList[0]);
// upload the file to the server side script
fileReference.addEventListener(Event.COMPLETE,
uploadCompleteHandler);
fileReference.upload(urlRequest);
// update the status text
statusText.text = "Uploading...";
private function uploadCompleteHandler(event:Event):void
statusText.text = "File Uploaded: " + event.target.name;
var file:FileReference = FileReference(event.target);
//var file:FileReference ;
outputTextArea.htmlText = "<img src='C:\\" + (file.name)
+ "'/>";
//myArray.push(outputTextArea.htmlText);
myArray.push("<img src='C:\\" + (file.name) + "'/>");
trace(outputTextArea.htmlText);
public function dodo():void
var image1:Image = new Image;
image1.source = outputTextArea.htmlText;
// myArray.push(outputTextArea.htmlText).valueOf();
// myArray.push(image1.source);
TileListdp.source = myArray;
image1.source =TileListdp.source;
//TileListdp.source = image1.data;
private function initData():void
TileListdp = new ArrayCollection();
]]>
</mx:Script>
<mx:Label text="Upload File From Flex to PHP"
fontWeight="bold"/>
<mx:Label text="Choose a file..." id="statusText"/>
<mx:Button click="uploadFile();" label="Upload File"/>
<mx:TileList x="195" y="10" width="532"
dataProvider="{TileListdp}"
height="207" id="myList" rowHeight="20" columnCount="1"
labelField="thumbnail" render="mx.controls.Image"
variableRowHeight="true" visible="true" wordWrap="true"
includeInLayout="true" direction="vertical" enabled="true">
</mx:TileList>
<mx:TextArea height="244" id="outputTextArea"
width="248"/>
<mx:Button label="Button" click="dodo();"/>
</mx:Application>
php code
<?php
$tempFile = $_FILES['Filedata']['tmp_name'];
$fileName = $_FILES['Filedata']['name'];
$fileSize = $_FILES['Filedata']['size'];
$fp = fopen("test.txt","a+");
fwrite($fp,$fileName."\r\n");
move_uploaded_file($tempFile, 'C:\\' . $fileName);
?>
<!--<script type="text/javascript"
language="javascript">window.location='C:\Documents and
Settings\Manohar\My Documents\Flex Builder
3\sample\bin-debug\dload.html'</script>-->

Similar Messages

  • How to load a tif image in flex

    Hi All,
    Is it possible to load a tif image in flex. If it's possible
    anyone guide me or send me some code snippets regarding how to
    display a tif image in flex.
    Regards,
    Dharma

    "flexdharma" <[email protected]> wrote in
    message
    news:ga2d96$p8h$[email protected]..
    >
    Hi All,
    > Is it possible to load a tif image in flex. If it's
    possible anyone guide
    > me or send me some code snippets regarding how to
    display a tif image in
    > flex.
    Convert it to the much more web-friendly png format.

  • How to read local large JPEG files and display into Images Tile

    Hi all,
    I can read the local multiple files by FLEX/AIR FileListEvent
    and loader to read the large JPEG files but cannot display them
    into a TileList. Since it is a number of images files, how can I
    put them into a thumbnail TileList.
    Please kindly advise.
    Regards,
    Billy

    1. So I would like to know which is the {color:#3366ff}best way to load local images in ImageView{color}.I'm no expert, but is there a reason that you are using Swing to do the loading?
    2. secondly, currently the system displays all images only after the completion of creating all images. {color:#3366ff}How to display images as and when they are created.{color} So that the user has a feeling that the images are loading.JavaFX Image class let you display a lightweight placeholder, and you can bind the progress to some kind of visual indicator. I don't think you can display an image that is partially loaded.
    def PATHS: String[] = [
        "C://Ariel Atom//ariel-atom-1.jpg",
        "C://Ariel Atom//ariel-atom-2.jpg",
        "C://Ariel Atom//ariel-atom-3.jpg",
        "C://Ariel Atom//ariel-atom-5.jpg"
    function getImage(path: String): Image {
        Image {
            url: "file:///{path}"
            backgroundLoading: true
    Stage {
        title: "Image Tiles"
        width: 1024
        height: 800
        scene: Scene {
            content: [
                Tile {
                    columns: 2
                    tileWidth: 400
                    tileHeight: 400
                    content: for (i in [0..3]) {
                        ImageView {
                            image: getImage(PATHS)

  • Embeding a .gif image in Flex Application.

    Hi All ,
         In my application , i have a requirement like : i need to play .gif images , But Flex does not support .gif animation , it will display .gif as normal .jpeg image.
    So i used : AnimatedGIFImage.as --> http://code.google.com/p/as3gif/
    But it is giving Error like :
    Please Help....

    I think that you are looking for a kind of this code. Am I right?
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.GradientPaint;
    import java.awt.geom.Rectangle2D;
    import javax.swing.JFrame;
    public class DemoPaint
         public static void main(String args[])
              GradientFrame gf = new GradientFrame("Gradient Frame");
              gf.setSize(300,200);
              gf.setResizable(false);
              gf.setVisible(true);
    class GradientFrame extends JFrame
         Color red_color = new Color(128,0,0);
         GradientFrame(String title)
              super(title);
         public void paint(Graphics g)
              Graphics2D g2 = (Graphics2D)g;
              GradientPaint gp = new GradientPaint(0,0,red_color,getWidth(),0,new Color(red_color.getRed(),red_color.getGreen(),red_color.getBlue(),0));
              g2.setPaint(gp);
              Rectangle2D rect = new Rectangle2D.Double(0,0,getWidth(),getHeight()/2);
              g2.fill(rect);
    }

  • Generic custom control that can display an image or swf?

    Hi,
    I want to create a custom control that can take an image or swf as an argument and display it in the same way.
    If the programmer uses this control (which essentially is a button with custom display) I want him to be able to just state the source and the text that is to be shown. Like this:
       <myControls:myButtonControl descriptionText="swf object" symbolObject="{Application.application.shape01swf}">
    or
       <myControls:myButtonControl descriptionText="img object" symbolObject="{Application.application.shape01img}">
    where shape01swf and shape01swf are embeded objects as follows:
       [Embed("../assets/swf/Shape01.swf")]
        public var shape01swf:Class;
       [Embed("../assets/images/Shape01img.jpg")]
       public var shape01img:Class;
    Which kind of object should I create in my custom control that can display this?
    Right now I have created a Class that extends VBox so that I can display the image/swf above the descriptionText.
    (I am using Flex 3.)

    Aha, so the Image control can use an swf as a source as well?
    I just assumed that it could not and I would have to use the SWFLoader to do it.
    So, this is my solution:
            override protected function createChildren():void{
                iconField = new Image();
                addChild(DisplayObject(iconField));
                textField = new Text();
                addChild(DisplayObject(textField));
                super.createChildren();
            private function init(e:Event):void{
                iconField.source = symbolObject;
                textField.text = descriptionText;
    Thanks!

  • Display *.bmp images or *.tiff images

    Hi All,
    Need help in displaying *.bmp / *.tiff images at runtime.
    I am working in an application where the user may upload
    images (jsp) in any format (jpg/gif/png/bmp/tif) and I need to
    display these images from an user interface built in Flex with zoom
    effects. I am able to display jpg/gif/png using the standard Image
    control with zoom but unable to display the bmp and tiff files.
    Is there any way to display tiff and bmp files?
    Please help.
    Regards,
    Paromita

    All is well now. I used the Revo Uninstaller (www.revouninstaller.com) which scoured the registry and deleted dozens of left-behind pieces, then I reinstalled off the disk using all the default settings.

  • Aperture 3 project does not display any images in one Project

    This is a strange situation.  The bullets below outline the situation:
    The project does not display any images
    When I place the pointer over the project it shows there are 500+ images
    I have located the RAW images stored in my aperture library
    I can pull up the images using a smart folder and searching for photos taken on the event day
    This is happening only to one of my projects that I know of (weird!!)
    I have tried to 're-add' the image by both importing and dragging and dropping into the project, neither works
    I tried the following basics:
    Fixed permissions
    Rebuilt the database
    Tried to re-import the data, but when I have the 'don't import duplicates' these are not an option
    Found the images in my Aperture library
    I created another project and drug all of the images into that project
    Any idea how I can fix this?
    My fear is that if I delete the original project, the original master images will be deleted.

    The most common cause of this is some sort of stuff in the search box at the top of the browser that you don't expect to be there. Just clear it and all your images should show up.
    RB
    One note - if you drug your images from one project to another it moves them vs copies them unless you hold down the option key.

  • Problem with displaying BLOB images on JSP page using a servlet

    hi. I have a big problem with displaying BLOB images using JSP. I have a servlet that connects to the oracle database, gets a BLOB image , reads it, and then displays it using a BinaryStream. The problem is , this works only when i directly call that servlet, that is http://localhost:8080/ImageServlet. It doesn't work when i try to use that servlet to display my image on my JSP page (my JSP page displays only a broken-image icon ) I tried several coding approaches with my servlet (used both Blob and BLOB objects), and they work just fine as long as i display images explicitly using only the servlet.
    Here's what i use : ORACLE 10g XE , Eclipse 3.1.2, Tomcat 5.5.16 , JDK 1.5
    here is one of my image servlet's working versions (the essential part of it) :
                   BLOB blob=null;
              rset=st.executeQuery("SELECT * FROM IMAGES WHERE ID=1");
              while (rset.next())
                   blob=((OracleResultSet)rset).getBLOB(2);
              response.reset();
              response.setContentType("image/jpeg");
              response.addHeader("Content-Disposition","filename=42.jpeg");
                    ServletOutputStream ostr=response.getOutputStream();
                   InputStream istr=blob.getBinaryStream(1L);
                    int size=blob.getBufferSize();
              int len=-1;
                    byte[] buff = new byte[size];
                         while ((len=istr.read( buff ))!=-1 ) {
                   ostr.write(buff,0,len);
             response.flushBuffer();
             ostr.close(); and my JSP page code :
    <img src="/ImageServlet" border="0"  > If you could just tell me what i'm doing wrong here , or if you could show me your own solutions to that problem , i would be very greatful ,cos i'm realy stuck here , and i'm rather pressed for time too. Hope someone can help.

    I turns out that it wasn't that big of a problem after all. All i had to do was to take the above code and place it into another JSP page instead of into a servlet like i did before. Then i just used that page as a source for my IMG tag in my first JSP. It works perfectly well. Why this doesn't work for servlets i still don't know, but it's not a problem form me anymore . Ofcourse if someone knows the answer , go ahead and write. I would still appriceatte it.
    here's the magic tag : <img src="ImageJSP.jsp" border="0"  > enjoy : )

  • Problem with display an image on JFrame in Java 6

    I'm trying to display an image on JFrame in this way:
    1.) I'm creating a variable in the class:
        private Image imgSpeaker = null;2.) I'm overiting the paint method:
    public void paint(Graphics g) {
            super.paint(g);   
            g.drawImage(imgSpeaker, 330, 230, null);  
        }3.) In the constructor I'm using this code:
       imgSpeaker = Toolkit.getDefaultToolkit().getImage("D:\\speaker.gif");
            MediaTracker trop = new MediaTracker(this);
            trop.addImage(imgSpeaker,0);
            try {
                trop.waitForID(0);    // waiting untill downloading progress will be complite
            } catch (Exception e) {
                System.err.println(e);
            }        The Image will be displayed on form, but if I catch the window and move it (for example: down as possible)
    the image is not refreshed (repainted). What I'm doing wrong? I've been used this solution in Java 5 and everything
    works perfectly. Any of described methods aren't depricated... Anyone can help me?

    Thanks for your code, I've been tryed to apply your solution (with create a Buffered Image), but it still not working correctly. Firstly, the image isn't loading, and secondly the basic problem is not give in. Why have you been using "bg2d.draw(img, x, y, w, h, frame);" not in the paint method?
    I'm use "Free Design" layout. Below I put on completly code from Netbeans.
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.MediaTracker;
    import java.awt.image.BufferedImage;
    public class ImageTest extends javax.swing.JFrame {
        private Image imgSpeaker = null;
        private BufferedImage bi = null;
        private MediaTracker trop = null;
        public ImageTest() { 
                initComponents();
                trop = new java.awt.MediaTracker(this);
                imgSpeaker = java.awt.Toolkit.getDefaultToolkit().getImage("D:\\speaker.gif");
                try {
                    trop.addImage(imgSpeaker, 0);
                    trop.waitForID(0);
                } catch (java.lang.Exception e) {
                    java.lang.System.err.println(e);
                bi = new java.awt.image.BufferedImage(100, 100, java.awt.image.BufferedImage.TYPE_INT_RGB);
                java.awt.Graphics2D bg2d = (java.awt.Graphics2D) bi.createGraphics();
                trop.addImage(bi, 1);
    //            java.io.File f = new java.io.File("D:\\speaker.gif");
    //            try {
    //                bi = javax.imageio.ImageIO.read(f);
    //            } catch (IOException e) {
    //               java.lang.System.err.println(e);
        public void paint(Graphics g) {
    //      super.paint(g);
           try {                                                   
                trop.waitForAll();                                 
            } catch (Exception e) {
                System.err.println(e);
            g.drawImage(bi, 50, 100, imgSpeaker.getHeight(this), imgSpeaker.getHeight(this), this);
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
        private void initComponents() {
            jButton1 = new javax.swing.JButton();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            jButton1.setText("jButton1");
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(283, Short.MAX_VALUE)
                    .addComponent(jButton1)
                    .addGap(44, 44, 44))
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap(252, Short.MAX_VALUE)
                    .addComponent(jButton1)
                    .addGap(25, 25, 25))
            pack();
        }// </editor-fold>
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new ImageTest().setVisible(true);
        private javax.swing.JButton jButton1;
    }

  • Display BLOB (image) column in (interactive) report

    Hi,
    I have a field called "picture" in my table "details" which is of type BLOB. i also have a field for "MIMETYPE" and "filename"
    i additionally have a "name" and "description" columns which i need to display along with the picture as columns in a report (preferably interactive).
    i have also modified the BLOB display format as per
    http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/apex31blob.htm
    what i am missing is the correct query. if possible, i would like to control the size of the picture rendered within the report like say 40*50.
    I have also referred to the thread
    APEX 3.1 Display BLOB Image
    But i don't know how to place the
    dbms_lob.getlength("BLOB_CONTENT") as "BLOB_CONTENT"
    in my query.
    The above also makes the report column as of type "number". is this expected?
    Any help would be much appreciated.
    Regards,
    Ramakrishnan

    You haven't actually said what the problem is?
    >
    I have a field called "picture" in my table "details" which is of type BLOB. i also have a field for "MIMETYPE" and "filename"
    i additionally have a "name" and "description" columns which i need to display along with the picture as columns in a report (preferably interactive).
    i have also modified the BLOB display format as per
    http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/apex/r31/apex31nf/apex31blob.htm
    what i am missing is the correct query.
    I have also referred to the thread
    APEX 3.1 Display BLOB Image
    But i don't know how to place the
    dbms_lob.getlength("BLOB_CONTENT") as "BLOB_CONTENT"
    >
    Something like:
    select
              name
            , description
            , dbms_lob.getlength(picture) picture
    from
              details
    if possible, i would like to control the size of the picture rendered within the report like say 40*50.For images close to this size it's easy to do this for declarative BLOB images in interactive reports using CSS. Add a style sheet with:
    .apexir_WORKSHEET_DATA td[headers="PICTURE"] img {
      display: block;
      width: 40px;
      border: 1px solid #999;
      padding: 4px;
      background: #f6f6f6;
    }where the <tt>PICTURE</tt> value in the attribute selector is the table header ID of the image column. Setting only one dimension (in this case the width) scales the image with the correct aspect ratio. (The border, padding and background properties are just eye candy...)
    However, scaling large images in the browser this way is a huge waste of bandwidth and produces poorer quality images than creating proper scaled down versions using image tools. For improved performance and image quality, and where you require image-specific scaling you can use the database ORDImage object to produce thumbnail and preview versions automatically, as described in this blog post.

  • Problem in creating client side PDF with image using flex and AlivePD

    I need a favor I am creating client side PDF with image using flex and AlivePDF for a web based application. Images have been generated on that pdf but it is creating problem for large size images as half of the image disappeared from that pdf.I am taking the image inside a canvas . How do i control my images so that they come fit on that pdf file for any image size that i take.
    Thanks in advance
    Atishay

    I am having a similar and more serious problem. It takes a
    long time to execute, but even attaching a small image balloons the
    pdf to 6MB plus. After a few images it gets up to 20MB. These are
    100k jpeg files being attached. The resulting PDF is too large to
    email or process effectively. Does anyone know how to reduce
    size/processing?

  • How do I display blob (image) in a Portal Report

    I am using 9ias 10222 and portal 30983 and I have a table that stores an image as a blob and have a varchar field to store the mime type. I have created a form to upload the image and can then query the form to display the image.
    How do I dislay the image in a Portal Report/Dynamic Page Component. I have followed note 68016.1 but the retrieve_img_data procedure does not work it gives a wwv-11230 error.
    Any ideas? Any help would be appreciated.
    Thanks
    Belinda

    Hi,
    Can you display what code you used for this? I followed note 172045.1 and everything compiles properly but when I run the report, I just get a box with a red X in it, like it is not finding the picture. I ran the procedure that downloads the image and it works fine from there. Thanks.

  • How can I display three images in video rate succession (60 Hz)?

    For a structured illumination microscope application, I have developed a VI that creates three images and displays them in rapid succession (as fast as the loop will go) on a second monitor.
    From the naked eye it's pretty apparent that the loop is not displaying the images at video rate.  Is there a way (perhaps with some sort of buffer) to get them to display faster?  Is WinShow simply not going to be fast enough, and if not, what's an alternative method of displaying the images?  If it helps, the images need only be displayed once each (the loop was just for testing).
    Also, what is a way to measure the frame rate output of the images?
    (sorry for the sloppy code, new to LabView)
    Thanks,
    -T
    Attachments:
    illuminationpattern.vi ‏31 KB

    Hello,
    Why don't  you try drawing one window, call IMAQ WindShow once outside of the loop, then redraw that window each iteration within the loop.  Hopefully this stops the flutter of the window.  You can build a 3 element array of the 3 IMAQ images then use an index array to alternate through which image you want to be redrawn into the single window.  The constant calling of IMAQ WindShow seems messy.
    Regards,
    Isaac S.
    Applications Engineer
    National Instruments

  • Displaying an image from a URL

    I have a program which visits a html page and creates a JComboBox with all the images from that page. When the user selects an image from the combo box it displays that image in a JLabel. This works fine with images that exist, when I try it with an image that doesn't exist I want it to realise that and display a message saying that "the image cannot be found". Heres part of my code that handles the selection:
    public void actionPerformed(ActionEvent f) {
                        JComboBox cb = (JComboBox)f.getSource();
                        String imageName = (String)cb.getSelectedItem();
                        try {
                             imageUrl = new URL(imageName);
                        catch (MalformedURLException ex) {
                             System.out.println("Image Collection Error: " + ex);
                        catch (Exception e) {
                             System.out.println("Some sort of exception: " + e);
                        picture.setIcon(new ImageIcon(imageUrl));
              });When I select a bad link image from the list I was hoping the catch blocks would trap it and I could make adjustments accordingly, this does not happen. No exception is thrown at all.
    Any ideas of what I can do??
    Bow_wow.

    Thanks for your help, I have changed it to the following code:
    ImageIcon imageToDisplay = new ImageIcon(imageUrl);
                        ImageIcon badImage = new ImageIcon("logo.jpg"); // An image I know exists
                        int status = imageToDisplay.getImageLoadStatus();
                        if (status == MediaTracker.COMPLETE) {
                             picture.setIcon(imageToDisplay);
                        else {
                             picture.setIcon(badImage);                              
                        }It works now, thanks again for your help!

  • How to display uploaded image in jsp page.

    Hello,
    I am using struts 1.2.9 and and have uploaded image on the server. Now what I want to do display the image in jsp page after clicking on one link in jsp. I have tried many thing to display image in jsp page. But I am getting an error during displaying image in jsp. I have displayed absolute path in servlet. and used InputStream and outputstream to display image in jsp page.
    Can any one help.
    Thanks in advance
    Manveer Singh

    Follow this. This topic is very popular recently on the forum.

Maybe you are looking for

  • Sales order is seen in MD04 but not on backorder report CO06.

    Hello friends, I went through several threads on backorder but couldn't find answers to my query.  Kindly help.  Thanks. - Are there any alternative to doing backorder processing ? - Can backorder processing be automated ?  How ?  What transaction ?

  • Data elements for IDoc Segments to non-SAP system

    Hi, I need to create IDocs for transferring data to non-SAP system. When I create segmet fields should I create new data elements for all the fields with attributes specific to receiving system? Because there are many fields where the field attribute

  • Gnome crashes randomly

    Gnome has been crashing randomly for the past 2 weeks and I finally am so tired of it so I posted this. It will just randomly fallback to gdm. Here is my Xorg.5.log. I hope you can make sense of what's going on. It seems like something about screens

  • Order of nodes in config.xml

    Hi, as the console does not offer all possible configuration options, I have to edit config.xml quite often. I think that it's quite inconvenient that the nodes in config.xml seem to be sorted in some kind of random order. Are there any ways to force

  • IWeb slideshows not showing...Safari only?

    During the last few days, when I check out iWeb slideshows I have created for my school using my Safari browser, the photos aren't displayed. All I see on my Mac is the "Play Slideshow" graphic and the number of pages are shown but nothing more. The