Copy link to clipboard
Copied
I inherited a program that worked in 2012 but no longer works. I tradced the issue to the last line of the following code. I am unsure how to fix it. The purpose of the application is to take a picture from the camera and export it as a jpg and email it.
function createJPG( m:MovieClip, q:Number, fileName:String )
{
var jpgSource:BitmapData = new BitmapData(540,715);
jpgSource.draw(m);
var jpgEncoder:JPGEncoder = new JPGEncoder(q);
var jpgStream:ByteArray = jpgEncoder.encode(jpgSource);
var header:URLRequestHeader = new URLRequestHeader("Content-type","application/octet-stream");
var jpgURLRequest:URLRequest = new URLRequest ( serverPath+"jpg_encoder_download.php?name=" + fileName + ".jpg");
jpgURLRequest.requestHeaders.push(header);
jpgURLRequest.method = URLRequestMethod.POST;
jpgURLRequest.data = jpgStream;
var jpgURLLoader:URLLoader = new URLLoader();
jpgURLLoader.load(jpgURLRequest);
navigateToURL(jpgURLRequest, "_top");
This is the error I get:
SecurityError: Error #3769: Security sandbox violation: Only simple headers can be used with navigateToUrl() or sendToUrl().
at global/flash.net::navigateToURL()
at index_2017_fla::MainTimeline/createJPG()[index_2017_fla.MainTimeline::frame1:128]
at index_2017_fla::MainTimeline/save()[index_2017_fla.MainTimeline::frame1:106]
you have to test on the server or change your security settings, Adobe - Flash Player : Settings Manager - Global Security Settings panel
Copy link to clipboard
Copied
are you testing on the server that contains the php file?
are you using a relative path to the php file?
Copy link to clipboard
Copied
I have the PHP file in the directory and what the previous employee did was "var jpgURLRequest:URLRequest = new URLRequest ( serverPath+"jpg_encoder_download.php?name=" + fileName + ".jpg");"
Copy link to clipboard
Copied
you have to test on the server or change your security settings, Adobe - Flash Player : Settings Manager - Global Security Settings panel
Copy link to clipboard
Copied
Thanks for the reply, I did both but it still won't save a jpg. I still get the same error.
Copy link to clipboard
Copied
you tested the file on your server and used a local path to the php?
Copy link to clipboard
Copied
Here is a link to the full program. It's written for an older version of flash and I can't figure out what broke and what didn't.
import flash.display.Bitmap; import flash.events.MouseEvent; import flash.disp - Pastebin.com
Copy link to clipboard
Copied
there's probably not a coding error. there's a security issue.
Copy link to clipboard
Copied
ah, okay. I'll try and look into it more.
Copy link to clipboard
Copied
>>
jpgURLLoader.load(jpgURLRequest);
navigateToURL(jpgURLRequest, "_top");
Why are you using both load and navigateToURL? If you want to post the request and also go to a page you'll need a different request.
Copy link to clipboard
Copied
Which request would be needed?