How use PHP to read image files from a folder and display them in Flex 3 tilelist.

Hello. I need help on displaying images from a folder dynamically using PHP and display it on FLEX 3 TileList. Im currently able to read the image files from the folder but i don't know how to display them in the TileList. This is my current code
PHP :
PHP Code:
<?php
//Open images directory
$imglist = '';
$dir = dir("C:\Documents and Settings\april09mpsip\My Documents\Flex Builder 3\PHPTEST\src\Assets\images");
//List files in images directory
while (($file = $dir->read()) !== false)
if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
echo "filename: " . $file . "\n";
$dir->close();
?>
FLEX 3 :
Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="pic.send();">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.rpc.events.FaultEvent;
import mx.events.ItemClickEvent;
import mx.rpc.events.ResultEvent;
public var image:Object;
private function resultHandler(event:ResultEvent):void
image = (event.result);
ta1.text = String(event.result);
private function faultHandler(event:FaultEvent):void
ta1.text = "Fault Response from HTTPService call:\n ";
]]>
</mx:Script>
<mx:TileList x="31" y="22" initialize="init();" dataProvider = "{image}" width="630" height="149"/>
<mx:String id="phpPicture">http://localhost/php/Picture.php</mx:String>
<mx:HTTPService id="pic" url="{phpPicture}" method="POST"
result="{resultHandler(event)}" fault="{faultHandler(event)}"/>
<mx:TextArea x="136" y="325" width="182" height="221" id="ta1" editable="false"/>
<mx:Label x="136" y="297" text="List of files in the folder" width="182" height="20" fontWeight="bold" fontSize="13"/>
</mx:Application>
Thanks. Need help as soon as possbile. URGENT.

i have made some changes, in the php part too, and following is the resulting code( i tried it, and found that it works.):
PHP Code:
<?php
echo '<?xml version="1.0" encoding="utf-8"?>';
?>
<root>
<images>
<?php
//Open images directory
$dir = dir("images");
//List files in images directory
while (($file = $dir->read()) !== false)
if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
echo "<image>" . $file . "</image>"; // i expect you to use the relative path in $dir, not C:\..........
//$dir->close();
?>
</images>
</root>
Flex Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
creationComplete="callPHP();">
<mx:Script>
<![CDATA[
import mx.rpc.http.HTTPService;
import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.rpc.events.FaultEvent;
import mx.events.ItemClickEvent;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
private var arr:ArrayCollection = new ArrayCollection();
private function callPHP():void
var hs:HTTPService = new HTTPService();
hs.url = 'Picture.php';
hs.addEventListener( ResultEvent.RESULT, resultHandler );
hs.addEventListener( FaultEvent.FAULT, faultHandler )
hs.send();
private function resultHandler( event:ResultEvent ):void
arr = event.result.root.images.image as ArrayCollection;
private function faultHandler( event:FaultEvent ):void
Alert.show( "Fault Response from HTTPService call:\n " );
]]>
</mx:Script>
<mx:TileList id="tilelist"
dataProvider="{arr}">
<mx:itemRenderer>
<mx:Component>
<mx:Image source="images/{data}" />
</mx:Component>
</mx:itemRenderer>
</mx:TileList>
</mx:Application>

Similar Messages

  • How to fetch the image file from oracle database and display it.

    hi... i've inserted the image file into the oracle database... now i want to retreive it and want to display it... can anybody help me... pls

    not a big deal dude... i fetched the image from database and saved it into my local hard disk.. but when tried to open it,ends up with no preview... dont know what d prob is... any idea... i've inserted the image as bytes n trying to fetch it as binary stream.. is that the problem... here im giving my insertion and retireving code.. jus go through it...
    Insertion code:_
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package PMS;
    import java.io.File;
    import java.io.FileInputStream;
    import java.sql.Blob;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    public class Browse_java
    static Connection con=null;
    public static void main(String args[])
    try{
    System.out.println("(browse.java) just entered in to the class");
    con = new PMS.DbConnection().getConnection();
    System.out.println("(browse.java) connection string is"+con);
    PreparedStatement ps = con.prepareStatement("INSERT INTO img_exp VALUES(?,?)");
    System.out.println("(browse.java) prepare statement object is"+ps);
    File file =new File("E:/vanabojanalu-/DSC02095.JPG");
    FileInputStream fs = new FileInputStream(file);
    System.out.println("lenth of file"+file.length());
    byte blob[]=new byte[(byte)file.length()];
    System.out.println("lenth of file"+blob.length);
    fs.read(blob);
    ps.setString(1,"E:/vanabojanalu-/DSC02095.JPG");
    ps.setBytes(2, blob);
    // ps.setBinaryStream(2, fs,(int)file.length());
    System.out.println("(browse.java)length of picture is"+fs.available());
    int i = ps.executeUpdate();
    System.out.println("image inserted successfully"+i);
    catch(Exception e)
    e.printStackTrace();
    finally
    try {
    con.close();
    } catch (SQLException ex) {
    ex.printStackTrace();
    and Retrieving code is:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package PMS;
    import java.beans.Statement;
    import java.io.*;
    import java.net.*;
    import java.sql.*;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import oracle.jdbc.OracleResultSet;
    * @author Administrator
    public class view_image2 extends HttpServlet {
    * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
    * @param request servlet request
    * @param response servlet response
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("image/jpeg");
    //PrintWriter out = response.getWriter();
    try
    javax.servlet.http.HttpServletResponse res=null;;
    int returnValue = 0;
    Connection con = null;
    PreparedStatement stmt = null;
    ResultSet rs = null;
    InputStream in = null;
    OutputStream os = null;
    Blob blob = null;
    //String text;
    //text=request.getParameter("text");
    //Class.forName("com.mysql.jdbc.Driver");
    con=new PMS.DbConnection().getConnection();
    System.out.println("jus entered the class");
    //String query = "SELECT B_IMAGE FROM img_exp where VC_IMG_PATH=?";
    //conn.setAutoCommit(false);
    PreparedStatement pst = con.prepareStatement("select b_image from img_exp where vc_img_path=?");
    System.out.println("before executing the query");
    pst.setString(1,"C:/Documents and Settings/Administrator/Desktop/Leader.jpg");
    rs = pst.executeQuery();
    //System.out.println("status of result set is"+rs.next());
    System.out.println("finished writing the query");
    int i=1;
    if(rs.next())
    System.out.println("in rs") ;
    byte[] byte_image=rs.getBytes(1);
    // byte blob_byte[]= new byte[(byte)blob.length()];
    //System.out.println("length of byte is"+blob_byte);
    //String len1 = (Oracle.sql.blob)rs.getString(1);
    //System.out.println("value of string is"+len1);
    //int len = len1.length();
    //byte [] b = new byte[len];
    //in = rs.getBinaryStream(1);
    int index = in.read(byte_image, 0, byte_image.length);
    System.out.println("value of in and index are"+in+" "+index);
    FileOutputStream outImej = new FileOutputStream("C://"+i+".JPG");
    //FileOutputStream fos = new FileOutputStream (imgFileName);
    BufferedOutputStream bos = new BufferedOutputStream (outImej);
    //byte [] byte_array = new byte [blob_byte.length]; //assuming 512k size; you can vary
    //this size depending upon avlBytes
    //int bytes_read = in.read(blob_byte);
    bos.write(index);
    /*while (index != -1)
    outImej.write(blob_byte, 0, index);
    index = in.read(blob_byte, 0, blob_byte.length);
    //System.out.println("==========================");
    //System.out.println(index);
    //System.out.println(outImej);
    //System.out.println("==========================");
    /*ServletOutputStream sout = response.getOutputStream(outImej);
              for(int n = 0; n < blob_byte.length; n++) {
                   sout.write(blob_byte[n]);
              sout.flush();
              sout.close();*/
    outImej.close();
    //i++;
    else
    returnValue = 1;
    catch(Exception e)
    System.out.println("SQLEXCEPTION : " +e);
    finally {
    //out.close();
    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    * Handles the HTTP <code>GET</code> method.
    * @param request servlet request
    * @param response servlet response
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    * Handles the HTTP <code>POST</code> method.
    * @param request servlet request
    * @param response servlet response
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    * Returns a short description of the servlet.
    public String getServletInfo() {
    return "Short description";
    // </editor-fold>
    }

  • Downloading image files from the server and saving them on local disk

    Hello,
    In an AIR app. i want to download number of image files,i have paths
    in an array.I am looping through the array and using URLLoader.Format
    is BINARY,now on the complete event of one file i dont know how to
    store the file on the disk as exactly which file has dispatched the
    event is not known.Please point out if my approach is incorrect or if
    any other ideas -plz share.

    Try the following:
    var imgURLs:Array = new Array();
    imgURLs[0] = "http://www.adobe.com/ubi/globalnav/include/adobe-lq.png";
    imgURLs[1] = "http://www.adobe.com/images/shared/download_buttons/get_adobe_air.png";
    var urlRequests:Array = new Array();
    var urlLoaders:Array = [];
    for (var i:int = 0; i < imgURLs.length; i++)
        loadURL(i);
    function loadURL(i:int):void
        var urlReq:URLRequest = new URLRequest(imgURLs[i]);
        urlRequests[i] = urlReq;
        var urlLoader:URLLoader = new URLLoader(urlReq);
        urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
        urlLoader.addEventListener(Event.COMPLETE,                
                    function (event:Event):void
                        var path:String = urlReq.url;
                        var urlLoader:URLLoader = event.target as URLLoader;
                        saveFileData(path, urlLoader.data);
    function saveFileData(path:String, data:ByteArray):void
        trace(path, data.bytesAvailable);
        // I'll let you write the code to save the data to a file path, based on the URL.
    You could also create a class that includes the event handler function and includes the code for loading the data. Then create a new instance of that class for each URL.

  • Reading multiples files from a folder and processing

    Hello everyone,
    Im working on a project to analyst and process Acoustic Emission Signals. My problem is that I have a folder that containts several files .txt. Every file contains 16 waveforms (16 channels) that I need to process with an equation to detect the arrival times of the waves.
    I have been working in this way : Running the labview code that open the file that I select .. then the processing happens on every wave and I click stop to select the file where I want to save the solutions. The solutions is only a vector of the 16 arrival times detected. Then I have to stop the code (by clicking Abort Execution) and repeat the process ... Run the code and bla bla bla .. and save on the same solution file that I used before.
    The ideal situation is to read the files whitout stoping the execution of the code .. For example clicking a buttom to pass to the next file and saving all the solutions to the same file. That is beacause sometimes Im going to have more than a 100 files and this will give me a hard time if a forget in which file I was working. The idea is to make an automatic process.
    Please .. I have been trying to find a solution to this while Im working in other part of the code. If someone could suggest me a solution it would be great.
    Thanks.

    Hello everyone,
    Well Im sorry if I didn't post my .vi ... I was working on it ... and I found a solution (whit some help that I found on the forums) but Im not happy at all ... because I still have to give the last part of the file name.
    For example at the beginning I have to input the file name without the final number of the event ...
    C:\Users\Irish\Desktop\Hydraulic Fracturing\E1_evento
    then I finish adding the file number that I want to process on the folder
    C:\Users\Irish\Desktop\Hydraulic Fracturing\E1_evento2.txt or 9.text or ... just the number ...
    This is the case when I want to process every file specifying the file .. but what could you suggest me to do process all the data file by file ?
    I attached the part of the code that Im using for this specific problem ...
    Im using Labview 8.5
    Thanks ...
    Message Edited by Alvaro_Ortiz on 08-26-2009 03:14 PM
    Attachments:
    MultReadFiles.vi ‏58 KB

  • I want to make a schedular which read xml files from a folder ,import in Indesign template then export as a pdf....

    i want to make a schedular probably in Coldfusion or using javascript ,  which read xml files from a folder ,import in Indesign template then export as a pdf....

    I don't think you understand: I want to open Dreamweaver and build a brand new site, then when I am done I want to host the dreamweaver site on the Business Catalyst platform. I dont want to use anything in BC to build the site, I just want to use the hosting platform. I do not want to import a BC site into dreamweaver or anything like that. I just want to use BC the same way I would use godaddy, or uhost or any other hosting provider. Based on your response you said that "of course its possible to build a BC site in Dreamweaver" I dont want to build a BC site, I want to build a Dreamweaver site and host it on the BC platform. Like I said before it doesnt seem like this is possible. As of now we can only build a new site in MUSE and integrate it into BC without using a BC template. Can you understand what I am saying. I DONT WANT TO USE A BC TEMPLATE, I WANT NOTHING TO DO WITH BC WHILE I AM BUILDING THE SITE WITH DREAMWEAVER, JUST LIKE MUSE DOES.

  • How to Copy an Image File from a Folder to another Folder

    i face the problem of copying an image file from a folder to another folder by coding. i not really know which method to use so i need some reference about it. hope to get reply soon, thx :)

    Try this code. Make an object of this class and call
    copyTo method.
    import java.io.*;
    import java.net.*;
    import java.util.*;
    public class FileUtil
    extends File {
    public FileUtil(String pathname) throws
    NullPointerException {
    super(pathname);
    public void copyTo(File dest) throws Exception {
    File parent = dest.getParentFile();
    parent.mkdirs();
    FileInputStream in = new FileInputStream(this); //
    Open the source file
    FileOutputStream out = new FileOutputStream(dest); //
    Open the destination file
    byte[] buffer = new byte[4096]; // Create an input
    buffer
    int bytes_read;
    while ( (bytes_read = in.read(buffer)) != -1) { //
    Keep reading until the end
    out.write(buffer, 0, bytes_read);
    in.close(); // Close the file
    out.close(); // Close the file
    This is poor object-oriented design. Use derivation only when you have to override methods -- this is just
    a static utility method hiding here.

  • How to delete a READ ONLY file from Directory

    Hi Friends,
    how to delete a READ ONLY file from Directory , file is in my system only.
    Please help me .
    note: its read only file.
    Thank you.
    Karthik.

    hI,
    try with this statement.
    delete dataset <datasetname>.
    this will definitely work.
    Regards,
    Nagaraj

  • How to read the file from a folder.

    Hi All,
    How to read the file from a folder or directory from the non sap server / remote server.
    Regards
    Sathis

    open dataset filename for input in text mode
                         encoding default.
    filename is character type variable with the destination filename.
    Edited by: Jino Augustine on Apr 19, 2010 1:31 PM

  • What are the commands available to read a file from application server and

    What are the commands available to read a file from application server and store the file into an internal table?

    Hi,
    To read a file from an Application Server to an Object there is a command in ABAP called <b>READ DATASET</b>. After that file is transported to that object you have to do a loop and put that data in an Internal Table.
    This statement exports data from the file specified in dset into the data object dobj. For dobj, variables with elementary data types and flat structures can be specified. In Unicode programs, dobj must be character-type if the file was opened as a text file.
    For dset, a character-type data object is expected - that is, an object that contains the platform-specific name of the file. The content is read from the file starting from the current file pointer. After the data transfer, the file pointer is positioned after the section that was read. Using the MAXIMUM LENGTH addition, the number of characters or bytes to be read from the file can be limited. Using ACTUAL LENGTH, the number of characters or bytes actually used can be determined.
    In a Unicode program, the file must be opened with an arbitrary access type; otherwise, an exception that cannot be handled will be triggered.
    If the file has not yet been opened in anon-Unicode program, it will be implicitly opened as a binary file for read access using the statement
    OPEN DATASET dset FOR INPUT IN BINARY MODE.
    . If a non-existing file is accessed, an exception that can be handled can be triggered.
    Influence of Access Type
    Files can be read independently of the access type. Whether data can be read or not depends solely on the position of the file pointer. If the latter is at the end of the file or after the file, no data can be read and sy-subrc will be set to 4.
    Influence of the Storage Type
    The import function will take place irrespective of the storage type in which the file was opened with the statement OPEN DATASET.
    If the file was opened as a text file or as a legacy text file, the data is normally read from the current position of the file pointer to the next end-of-line marking, and the file pointer is positioned after the end-of-line marking. If the data object dobj is too short for the number of read characters, the superfluous characters and bytes are cut off. If it is longer, it will be filled with blanks to the right.
    If the file was opened as a binary file or as a legacy-binary file, as much data is read that fits into the data object dobj. If the data object dobj is longer than the number of exported characters, it is filled with hexadecimal 0 on the right.
    If the specified storage type makes conversion necessary, this is executed before the assignment to the data object dobj. Afterwards, the read data is placed, byte by byte, into the data object.
    System Fields
    sy-subrc Meaning
    0 Data was read without reaching end of file.
    4 Data was read and the end of the file was reached or there was an attempt to read after the end of the file.
    Thanks,
    Samantak.
    <b>Rewards points for useful answers.</b>

  • How do I copy printer software files from a folder on my desktop to a CD?

    How do I copy printer software files from a folder on my desktop to a CD?

    Select all the files, right click and choose burn.

  • I want read PDF file from SAP directory and create a spool request or print

    Hi all,
    I want read PDF file from SAP directory and create a spool request or print the pdf through SAP. Can any body  help me in this.
    Also please write to me if its possible to open PDF from SAP directory to adobe pdf reader.
    Thanks in advance,
    Sunny

    Hi Sunny,
    Check these links.
    http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
    http://www.erpgenie.com/sap/abap/pdf_creation.htm
    http://www.geocities.com/mpioud/Z_EMAIL_ABAP_REPORT.html
    http://www.thespot4sap.com/Articles/SAP_Mail_SO_Object_Send.asp
    http://www.sapdevelopment.co.uk/reporting/email/attach_xls.htm
    Hope this resolves your query.
    Reward all the helpful answers.
    Regards

  • Hi, i purchased a 2 dvd digital set. i cant just download it straight to my ipad. they said i have to down load it to my i tunes, then can transfer to i pad. im not seeing how to click the files from my email, and get them into the i tunes acct... ugh.

    hi, i purchased a 2 dvd digital set. i cant just download it straight to my ipad. they said i have to down load it to my i tunes, then can transfer to i pad. im not seeing how to click the files from my email, and get them into the i tunes acct... ugh.
    i do not have a mac home pc. just a regular pc

    I had the same problem after I gave my old iPad to my parents and tried to install Netflix. This is what you have to do:  Open iTunes on your computer, the one you sync your iPad to. Then go to iTunes Store and search for and download Netflix app. After you download it, if your iPad is set to download new purchases it may start downloading on your iPad. If so, tap and hold to delete the app (because it is trying to install the new version on the iPad) Next step, go to the App Store on your iPad and find Netflix and it should say install since you already purchased it on the computer. Tap to install, and it will say the version is not compatible, tap to download a previous version. Click that and it will install the older version!    One more thing, if and when you sync to your computer again it will say something like " Unable to install Netflix on your iPad" Just click the box to never remind you again, because it's trying to sync the newer Netflix app to your iPad, but it doesn't work so it displays the message. The old app will remain on the ipad. Hope this helps, good luck

  • Reading the contents of a folder and store them in the database using 6i

    Hi all,
    I'm using developer 6i and oracle 8i,now am building personnel database,every employee has many certificates (graduate certificates,post-graduate certificates and work experience certificates),I want to scan all these certificates,put them in a folder ,give the form (employee form ) the path to the folder and the form read the contents of the folder (3 or 4 image files for example) dynamically and store them in the database.
    All examples I came across explain how to load a defined image file name into oracle database,but what if the image file name is not defined (i,e dynamically generated by the scanner).
    Hope I explained the case.
    Thanks in advance

    Sorry mhdamer,
    I read the example and thought it could be modified to retreive a directory listing. There is a way to do what you want, but you will have to check to see if you have the D2kwutil.pll installed with Forms 6i. If you do not have it installed you can download the pll from OTN. This Forms Library will only work on Windows, so if you want this functionality on a non-windows machine, it will not work. Read the D2KWUTIL.html for details on how to use this library. There are also some good posts here in the forums on how to use this library. Just search on D2KWUTIL.PLL.
    Craig...

  • Ok I can't seem to get my apps,music, or photos from my iCloud from when I first setup iCloud on a iPhone 4. How do I get my things back from the iCloud and get them to my new device?

    Ok I can't seem to get my apps,music, or photos from my iCloud from when I first setup iCloud on a iPhone 4. How do I get my things back from the iCloud and get them to my new device?

    If you no longer have the phone or have any Backup of it at all, you can re-download your apps and your content from the iTunes Store by logging into your Apple ID at settings> iTunes & App Store. Unfortunately you can no longer recover the data that was associated with those apps.
    So far as your photos go, you can recover any photos that were in photo stream and taken less than 30 days ago by logging in with your Apple ID to settings> iCloud> photos. Unfortunately you will be unable to recover any photos from your camera roll.

  • How can i erase my .me mails from my iPhone and keep them in the server

    how can i erase my .me mails from my iPhone and keep them in the server

    You can't. The iPhone doesn't actually store all your emails anyway. It is showing you what is on the server directly.
    Only the most recently accessed emails are cached (stored temporarily) on your phone for access when you are offline. If you delete an email from your iPhone, you are actually deleting it from the server.

Maybe you are looking for

  • Receiving oracle.jdbc.driver error when trying to connect

    Setup: Windows 7 64bit 4GB ram SQL Developer 3.2.20.09 Java platform 1.6.0_37 Oracle IDE 3.2.20.09.87 Hello, I'm going to start by saying I'm a rank amateur when it comes to using and understand SQL developer. My entire need for this program is to co

  • Save excel book

    I have a program that takes 3 different measurements 200 different times, and sends them into a book in excel.  Therefore, I would like to have it automatically save the Excel book containing the measurements after all 200 have been taken.  I am usin

  • Find out free hand sql reports

    Hi All, I need find out free hand sql reports we have above 3000 reports and we are using business objects 6.5. Could you please tell me any one how track these reports which table these informations. Advance Thanks. Regards,

  • Proposal for what Spotlight should be in iOS

    Here is a proposal for what Spotlight should be in iOS http://www.youtube.com/watch?v=LxICuQFzBU0 At it's core, it's a filtering system for Spotlight results. However, the system goes deeper than that; it allows for searching through all applications

  • My Ipod Touch won't restore after full reset!!! please help fast!!!

    My Ipod touch 3g 8gb on 3.1.3 got some major problems recently. When I wanted to take a snapshot it just doesn't appear in photos. When I wanted to save an image from Safari it doesn't appear in photos. Then I got fed up and pressed Reset Settings. T