Adobe Dreamweaver Forums



Last 10 THreads :         gesture driven scrolling list (Last Post : cntpmaxn - Replies : 64 - Views : 953 )           »          Formatting Text Paragraph (Last Post : BudHud - Replies : 0 - Views : 1 )           »          Tutorial Announcement :: Dynamic DropDwon Accordion Panel :: (Last Post : Günter_Schenk@adobeforums.com - Replies : 1 - Views : 2 )           »          Locking resize handles in browser. (Last Post : Jasper Thayer - Replies : 9 - Views : 10 )           »          Pushy div (Last Post : howeaver - Replies : 2 - Views : 3 )           »          adding a tag in replay history (Last Post : DynV - Replies : 6 - Views : 22 )           »          IE7 & CSS Opacity (Last Post : Al Sparber - PVII - Replies : 2 - Views : 3 )           »          file directory. (Last Post : lachy455 - Replies : 9 - Views : 10 )           »          Updating Templates (Last Post : Murray *ACE* - Replies : 3 - Views : 4 )           »          Re: Why can't Snit ever tell the truth? Is it a genetic problem? (Last Post : Steve Carroll - Replies : 0 - Views : 1 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flex
 
Tags:

Reply
  #1 (permalink)  
Old 07-24-2008, 01:23 PM
007none
 
Posts: n/a
Diggs:
Default filerefrence

Hi i am trying to upload file with php... Now this is working properly but when
i select a file then click on upload it's saving the file again without
selecting any file if i will again click on upload it will again save the same
file ..
I want to prevent this mean to say if a user not selecting file again file
must not be uploaded again .....
Please help me ..


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

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
public var file:FileReference;

public function selectFile():void
{
file = new FileReference();
file.addEventListener(Event.SELECT, fileSelected);
file.addEventListener(DataEvent.UPLOAD_COMPLETE_DA TA,
uploadDataComplete);
file.addEventListener(Event.COMPLETE, uploadComplete);
file.addEventListener(IOErrorEvent.IO_ERROR, handleError);
file.browse();
}

public function handleError(event:IOErrorEvent):void
{
status_txt.text = 'ERROR: ' + event.text + '\n';
}
public function fileSelected(event:Event):void
{
file = FileReference(event.target);
file_txt.text = file.name;
status_txt.text = 'upload file: '+ file.name + '\n';

}

public function uploadDataComplete(eventataEvent):void
{
var result:XML = new XML(event.data);
status_txt.text += 'Upload Data Complete\n'
status_txt.text += 'RESULT: ' + result.toString() + '\n'
status_txt.text += 'STATUS: ' + result.status + '\n';
status_txt.text += 'MESSAGE: '+ result.message;
}

public function uploadComplete(event:Event):void
{
status_txt.text += 'Upload complete\n';

}

private function upload():void
{

var request:URLRequest = new URLRequest();
request.url = "http://localhost/myupload.php";
file.upload(request);
}


]]>
</mx:Script>
<mx:VBox>
<mx:TextInput id="file_txt"/>
<mx:Button id="select_btn" label="select" click="selectFile();"/>
<mx:Button label="upload" click="upload();"/>
<mx:TextArea id="status_txt" width="400" height="200"/>
</mx:VBox>
</mx:Application>

Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-24-2008, 05:43 PM
GraspDiver
 
Posts: n/a
Diggs:
Default Re: filerefrence

I would suspect that the Event.SELECT listener is begin fired even if no file
is selected and that the object file_txt still contains the file name from the
previous action, so it uploads that file again. try setting file_txt.text=""
before assigning it file.name.

Reply With Quote
  #3 (permalink)  
Old 07-25-2008, 07:29 AM
007none
 
Posts: n/a
Diggs:
Default Re: filerefrence

Thanks for your reply ... i Have tried your suggestion but it's not the
solution ... Until and Up to i will not remove file name from file reference
object ,it will again upload it ... But i don't know how to remove file name
from file object ...

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 01:09 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk