This is the solution in Prototype.
Original concept provided by Ben Nadel and translated to Prototype by Mahesh
---------------

index.htm----
-------------

<script type="text/javascript" src="prototype-1.6.0.2.js"></script>

<script type="text/javascript">
Event.observe(window, 'load', function(){
        Event.observe('file_upload', 'change', function(){
                $('form').writeAttribute({enctype:"multipart/form-data", 
method:"post", action:"cffile.cfm", target:"RSIFrame"});
                $('form').insert(new Element("iframe", {id: "RSIFrame", name: 
"RSIFrame", style: "width: 0px; height: 0px; border: 0px;", src: 
"blank.html"}));
                $('form').submit();
        });
});

function showResult(result){
$('file_upload').remove();
$('upload_update').insert(new Element("a", {href: "http://localhost/upload/"; + 
result}).update("Uploaded Image"));
}
</script>

<form id="form">
<input name="file_upload" id="file_upload" type="file" size="60" />
<span id="upload_update"></span>
</form>

For the above script to work across browsers, do not set the form enctype in 
the prototype writeAttribute, instead add it to the form, as IE will not do the 
upload, if the form is set with the encType through JS.

-------------
---end-------

cffile.cfm---
-------------

<cffile action="upload" filefield="file_upload" 
destination="d:/inetpub/wwwroot/" nameconflict="MAKEUNIQUE">

<script type="text/javascript">
<cfoutput>
window.parent.showResult('#file.serverfile#');
alert('#file.serverfile#');
</cfoutput>
</script>

-------------
---end------- 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312765
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to