perspolis
09-03-2007, 09:14 AM
Hi,
I am trying to create multiple instance of file upload but it is not working. for example I have two instance of file upload, I use the first instance and select a file. Then the data will be passed to second instance.
here is my sample code
<canvas>
<include href="fileupload.lzx"/>
<class name="mine>
<fileUpload name="myFileUpload">
<method name="onComplete" args="fr"><![CDATA[
canvas.progressBar.setValue(100);
canvas.upload.setAttribute('enabled', false);
]]>
</method>
<method name="onProgress" args="fr, bytesLoaded, bytesTotal"><![CDATA[
canvas.progressBar.setValue(bytesLoaded * 100 / bytesTotal);
]]>
</method>
<method name="onSelect" args="fr"><![CDATA[
canvas.txtFile.setText(getName());
canvas.upload.setAttribute('enabled', true);
]]>
</method>
</fileUpload>
<edittext x="10" y="10" width="200" name="txtFile" enabled="false"/>
<button x="210" y="11" text="Browse...">
<method event="onclick"><![CDATA[
myFileUpload.browse();
]]>
</method>
</button>
<button name="upload" x="290" y="11" text="Upload" enabled="false">
<method event="onclick"><![CDATA[
myFileUpload.upload('../myServlet'); // This should be the complete URL where we want to upload the file
]]>
</method>
</button>
<view name="progressBar" x="356" y="11" width="50" height="24" bgcolor="#666666">
<view x="1" y="1" width="48" height="22" bgcolor="#FFFFFF"/>
<view name="status" x="1" y="1" height="22" bgcolor="#BBBBFF"/>
<text name="percent" x="5" y="3" fontstyle="bold" fgcolor="#6666FF"/>
<method name="setValue" args="value"><![CDATA[
status.setAttribute('width', value * 48 / 100);
percent.setText(Math.round(value) + '%');
]]>
</method>
</view>
</class>
<simplelayout axis="y" spacing="10"/>
<mine/>
<mine/>
</canvas>
----------------
and the fileupload.lzx
<library>
<class name="fileUpload">
<method event="oninit" args="invoker"><![CDATA[
fr = new flash.net.FileReference();
fr.addListener(invoker);
]]>
</method>
<method name="browse"><![CDATA[
fr.browse();
]]>
</method>
<method name="getName"><![CDATA[
return fr.name;
]]>
</method>
<method name="upload" args="url"><![CDATA[
fr.upload(url);
]]>
</method>
</class>
</library>
thanks for your help
I am trying to create multiple instance of file upload but it is not working. for example I have two instance of file upload, I use the first instance and select a file. Then the data will be passed to second instance.
here is my sample code
<canvas>
<include href="fileupload.lzx"/>
<class name="mine>
<fileUpload name="myFileUpload">
<method name="onComplete" args="fr"><![CDATA[
canvas.progressBar.setValue(100);
canvas.upload.setAttribute('enabled', false);
]]>
</method>
<method name="onProgress" args="fr, bytesLoaded, bytesTotal"><![CDATA[
canvas.progressBar.setValue(bytesLoaded * 100 / bytesTotal);
]]>
</method>
<method name="onSelect" args="fr"><![CDATA[
canvas.txtFile.setText(getName());
canvas.upload.setAttribute('enabled', true);
]]>
</method>
</fileUpload>
<edittext x="10" y="10" width="200" name="txtFile" enabled="false"/>
<button x="210" y="11" text="Browse...">
<method event="onclick"><![CDATA[
myFileUpload.browse();
]]>
</method>
</button>
<button name="upload" x="290" y="11" text="Upload" enabled="false">
<method event="onclick"><![CDATA[
myFileUpload.upload('../myServlet'); // This should be the complete URL where we want to upload the file
]]>
</method>
</button>
<view name="progressBar" x="356" y="11" width="50" height="24" bgcolor="#666666">
<view x="1" y="1" width="48" height="22" bgcolor="#FFFFFF"/>
<view name="status" x="1" y="1" height="22" bgcolor="#BBBBFF"/>
<text name="percent" x="5" y="3" fontstyle="bold" fgcolor="#6666FF"/>
<method name="setValue" args="value"><![CDATA[
status.setAttribute('width', value * 48 / 100);
percent.setText(Math.round(value) + '%');
]]>
</method>
</view>
</class>
<simplelayout axis="y" spacing="10"/>
<mine/>
<mine/>
</canvas>
----------------
and the fileupload.lzx
<library>
<class name="fileUpload">
<method event="oninit" args="invoker"><![CDATA[
fr = new flash.net.FileReference();
fr.addListener(invoker);
]]>
</method>
<method name="browse"><![CDATA[
fr.browse();
]]>
</method>
<method name="getName"><![CDATA[
return fr.name;
]]>
</method>
<method name="upload" args="url"><![CDATA[
fr.upload(url);
]]>
</method>
</class>
</library>
thanks for your help