I’m using the following script to upload files though Flash > PHP
[AS]System.security.allowDomain(“http://www.eclipseprint.com/”);
import flash.net.FileReference;
var listener:Object = new Object();
listener.onSelect = function(selectedFile:FileReference):Void {
selectedFile.upload(“http://www.eclipseprint.com/eclipsecart/upload.php”);
};
listener.onOpen = function(selectedFile:FileReference):Void {
main_mc.ploader._alpha = 100;
};
listener.onComplete = function(selectedFile:FileReference):Void {
new mx.transitions.Tween(main_mc.ploader, “_alpha”, mx.transitions.easing.Regular.easeIn, 100, 0, 35);
main_mc.form.txtFN.text = selectedFile.name;
main_mc.form.loadVariables(“http://www.eclipseprint.com/eclipsecart/email.php”, “POST”);
main_mc.txtStatus.text = “Your file “+selectedFile.name+” has been sent.”;
main_mc.form.txtFN.text = “”;
};
listener.onHTTPError = function(file:FileReference):Void {
main_mc.txtStatus.text = "onHTTPError: "+file.name;
};
listener.onIOError = function(file:FileReference):Void {
main_mc.txtStatus.text = "onIOError: "+file.name;
};
listener.onSecurityError = function(file:FileReference, errorString:String):Void {
main_mc.txtStatus.text = "onSecurityError: “+file.name+” errorString: "+errorString;
};
listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
//trace(“onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
bL = bytesLoaded;
bT = bytesTotal;
per = Math.round((bL/bT)100);
main_mc.ploader.tbar._width = per;
//form.ploader.txt.text = per;
/ if (old == undefined) {
speed = 0;
old = 0;
markspeed = setInterval(function () {
speed = bL/1024-old;
old = bL/1024;
}, 1000);
}
if(speed.toString() == “NaN” || speed == undefined || speed < 0) {
speed == 0;
}/
// loadbar.label = “Uploading…”+Math.floor(per)+"% “+Math.floor(speed)+“Kb/sec”;
};
var theFile:FileReference = new FileReference();
theFile.addListener(listener);
function uploadFile(event:Object):Void {
theFile.browse([{description:“All Files”, extension:”.*”}]);
}
[/AS]
<?php
//$MAXIMUM_FILESIZE = 1024 * 200000000; // 200KB
$MAXIMUM_FILE_COUNT = 1000; // keep maximum 1000 files on server
echo exif_imagetype($_FILES['Filedata']);
//if ($_FILES['Filedata']['size'] <= $MAXIMUM_FILESIZE) {
move_uploaded_file($_FILES['Filedata']['tmp_name'], "http://www.eclipseprint.com/eclipsecart/uploads/".$_FILES['Filedata']['name']);
//rename("./temporary/".$_FILES['Filedata']['name'], "./uploads/".$_FILES['Filedata']['name']);
//}
$directory = opendir('http://www.eclipseprint.com/eclipsecart/uploads/');
$files = array();
while ($file = readdir($directory)) {
array_push($files, array('http://www.eclipseprint.com/eclipsecart/uploads/'.$file, filectime('http://www.eclipseprint.com/eclipsecart/uploads/'.$file)));
}
usort($files, sorter);
if (count($files) > $MAXIMUM_FILE_COUNT) {
$files_to_delete = array_splice($files, 0, count($files) - $MAXIMUM_FILE_COUNT);
for ($i = 0; $i < count($files_to_delete); $i++) {
unlink($files_to_delete[$i][0]);
}
}
print_r($files);
closedir($directory);
function sorter($a, $b) {
if ($a[1] == $b[1]) {
return 0;
} else {
return ($a[1] < $b[1]) ? -1 : 1;
}
}
?>
and it is throwing the onSecurityError string “securitySandboxError”. I have set permissions for both files to 777, but it continues to error. Does anyone spot a fault in my code or have any idea what would cause this? Wierd thing is, I’ve used this script before with success. Perhaps the integration with osCommerce would cause it, but i’m not sure. Any ideas?