Hi,

We did the same concept in flex using JSP not PHP. Anyway we pasted the
.mxml and .jsp file coding for your reference. Hope this will give good idea
to do in php.

*.mxml file*


<?xml version="1.0" encoding="utf-8"?>

<!--
http://blog.flexexamples.com/2007/09/21/uploading-files-in-flex-using-the-filereference-class/-->

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="vertical"
verticalAlign="middle" backgroundColor="white"

creationComplete="init();">

<mx:Script>

<![CDATA[
*

import* mx.controls.Alert;

[*Bindable*]
*

private* *var* sessiondb:String=*""*;

[*Bindable*]
*

private* *var* sessionbrch:String=*""*;

[*Bindable*]
*

private* *var* newalphabet:String=*""*;

[*Bindable*]
*

private* *var* searchtype:String=*""*;
*

private* *var* fileRef:FileReference;
*

private* *const* FILE_UPLOAD_URL:String = *"
http://000.000.0.00:8080/xxx/flexupload2.jsp"*;
*

private* *function* init():*void*

{

fileRef = *new* FileReference();

fileRef.addEventListener(Event.SELECT, fileRef_select);

fileRef.addEventListener(ProgressEvent.PROGRESS, fileRef_progress);

fileRef.addEventListener(Event.COMPLETE, fileRef_complete);

}
*

private* *function* browseAndUpload():*void*

{

*var* filterss:Array = [];

filterss.push(*new* FileFilter(*"PPack"*, *
"*.jpg;*.jpeg;*.gif;*.png;*.tiff;*.tif"*));

fileRef.browse(filterss);

message.text = *""*;

}
*

private* *function* fileRef_select(evt:Event):*void*

{

*try*

{

message.text = *"size (bytes): "* + numberFormatter.format(fileRef.size);

fileRef.upload(*new* URLRequest(FILE_UPLOAD_URL));

}

*catch* (err:Error)

{

message.text = *"ERROR: zero-byte file"*;

}

}
*

private* *function* fileRef_progress(evt:ProgressEvent):*void*

{

progressBar.visible = *true*;

}
*

private* *function* fileRef_complete(evt:Event):*void*

{

message.text += *" (complete)"*;

progressBar.visible = *false*;

sessiondb=Application.application.parameters.sessiondb;

sessionbrch=Application.application.parameters.sessionbr;

newalphabet = fileRef.name;

searchtype = *"Insert"*;

mstprojectUpload.send(mstfileupload);

}

]]>

</mx:Script>

<mx:Model id="mstfileupload">

<root>

<mode>Image</mode>

<fname>{newalphabet}</fname>

<type>{searchtype}</type>

<sessiondb>{sessiondb}</sessiondb>

<sessionbranch>{sessionbrch}</sessionbranch>

</root>

</mx:Model>

<mx:HTTPService id="mstprojectUpload" useProxy="false" method="POST" url="
mstprojectprocess.htm"/>

<mx:NumberFormatter id="numberFormatter" />

<mx:Button label="Upload file" click="browseAndUpload();" />

<mx:Label id="message" />

<mx:ProgressBar id="progressBar" indeterminate="true" visible="false" />

</mx:Application>
*.jsp File*
<%...@page import="org.apache.commons.fileupload.FileItemFactory"%>
<%...@page import="org.apache.commons.fileupload.disk.DiskFileItemFactory"%>
<%...@page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%>
<%...@page import="org.apache.commons.fileupload.FileItem"%>
<%...@page import="java.util.List"%>
<%...@page import="java.util.Iterator"%>
<%...@page import="java.io.File"%>
<%...@page import="java.io.FileOutputStream"%>
<%...@page import="java.io.InputStream"%>
<%
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List  items = upload.parseRequest(request);
Iterator iter = items.iterator();
while (iter.hasNext())
{
   FileItem item = (FileItem) iter.next();
   if (item.isFormField())
   {
      String name = item.getFieldName();
      String value = item.getString();
   }
   else
   {
      String fieldName = item.getFieldName();
      String fileName = item.getName();
      String contentType = item.getContentType();
      boolean isInMemory = item.isInMemory();
      long sizeInBytes = item.getSize();
      byte[] data = item.get();
      FileOutputStream fileOutSt = new
FileOutputStream("/xx/xxx/xx/xx/xx/xx/"+fileName);
      fileOutSt.write(data);
      fileOutSt.close();
   }
}
%>

Thanks,
Ramya
On Wed, Aug 26, 2009 at 10:41 PM, sheetal <sheetalnilw...@gmail.com> wrote:

>
> Hi,
> I am having an image-
> ex- ur pic is on the page,nw on a button click i want to save this on
> server.How do i send it to server.and hw does the php code there
> handle it.Plz share ur ideas.
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to flex_india@googlegroups.com
To unsubscribe from this group, send email to 
flex_india+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to