I’m currently making a video uploading website as a little fun project, I have managed to get the player working and am now making an upload system in flash. The problem I am having is that I get the error “#2038: File I/O Error” when using fileRef.size() however only when you give the file reference very large files. I’m using the size function because I want to limit file sizes to under 2gb and I don’t want to waste the bandwidth to only have to delete the file after the php checks the size. Finally here is the code I have:
uploadBTN.visible = false;uploadBar.visible = false;
uploadBorder.visible = false;
var URLrequest:URLRequest = new URLRequest("http://localhost/video_system/uploader_script.php");
// Assign the image types Filter
var vidTypes:FileFilter = new FileFilter("Videos(.flv, .mp4)","*.flv; *.mp4");
// Add both filter types to an array
var allTypes:Array = new Array(vidTypes);
// Set the FileReference name
var fileRef:FileReference = new FileReference();
fileRef.addEventListener(Event.SELECT, syncVariables);
fileRef.addEventListener(Event.COMPLETE, completeHandler);
fileRef.addEventListener(ProgressEvent.PROGRESS, progressHandler);
fileRef.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
browseBTN.addEventListener(MouseEvent.CLICK, browse);
uploadBTN.addEventListener(MouseEvent.CLICK, upload);
function browse(event:MouseEvent):void
{
fileRef.browse(allTypes);
}
function errorHandler (event:IOErrorEvent):void
{
trace("hello");
dispatchEvent(event);
}
function upload(event:MouseEvent):void
{
fileRef.upload(URLrequest);
}
function completeHandler(event:Event):void
{
uploadBTN.visible = false;
uploadBar.visible = false;
uploadBorder.visible = false;
fileDisplay.text = "";
}
function syncVariables(event:Event):void
{
var size:Number = 0;
size = fileRef.size;
if (size < 20000000 && size > 0)
{
fileDisplay.text = " " + fileRef.name;
uploadBTN.visible = true;
uploadBar.visible = true;
uploadBorder.visible = true;
uploadBar.width = 0;
var variables:URLVariables = new URLVariables();
variables.accountID = "1";
URLrequest.method = URLRequestMethod.POST;
URLrequest.data = variables;
}
else
{
fileDisplay.text = " File too big (Larger than 2GB)";
}
}
function progressHandler(event:ProgressEvent):void
{
uploadBar.width = Math.ceil(200 * (event.bytesLoaded / event.bytesTotal));
}
Thank you so much for any help,
Andy A