开发者

Flex Problem with uploading files to server text=Error #2049: Security sandbox violation

I am trying to upload files from a client's browser to server using Flex .For this i have used the FileReference class to call a servlet which is doing the uploading . Below is the code for uploadHandler function.

private function uploadHandler(event:Event):void
            {
                var url:String="http://localhost/upload/WelcomeServlet";
                var request:URLRequest=new URLRequest(url);
                request.method=URLRequestMethod.POST;
                var variables:URLVariables=new URLVariables();
                variables.employeeID="sam";
                request.data=variables;             
                file.upload(request);
            }

As URLRequest does a http request ,i have added the network policy file crossdomain.xml in the root folder of my tomcat server .below is the xml

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"> 
<cross-domain-policy>
    <site-control permitted-cross-domain-policies="All"/>
    <allow-access-from domain="*"  secure="false" />
</cross-domain-policy>

Still i get the error below on trying to upload a file :

Error #2044: Unhandled SecurityErrorEvent:. text=Error #2049: Security sandbox violation: http://mysite.com/upload/upload.swf cannot upload data to http://localhost/upload/WelcomeServlet.
    at upload/creationCompleteHandler()[C:\Users\Documents\Flex Builder 3\upload\src\upload.mxml:22]
    at upload/___upload_Application1_creationComplete()[C:\Users\Documents\Flex Builder 3\upload\src\upload.mxml:4]
    at flash.events::EventDispatcher/dispa开发者_开发百科tchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9298]
    at mx.core::UIComponent/set initialized()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:1169]
    at mx.managers::LayoutManager/doPhasedInstantiation()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:718]
    at Function/http://adobe.com/AS3/2006/builtin::apply()
    at mx.core::UIComponent/callLaterDispatcher2()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8628]
    at mx.core::UIComponent/callLaterDispatcher()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8568]

it works fine when i am trying to upload from localhost . DO i need to add any additional compiler arguments ? i am using flash player 10 and apache tomcat 6.0.20 . This error is bugging me from a long time now , would appreciate any help

Thanks sanre6


Why not to change this string:

var url:String="http://localhost/upload/WelcomeServlet";

To:

var url:String="/WelcomeServlet";

?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜