我有以下代码:
private function uploadFile(file:File, packageId:String):void {
try {
var fullpath:String = file.nativePath;
var filename:String = fullpath.substr(fullpath.lastIndexOf("/")+1,fullpath.length);
packageItem.status = "Uploading file: "+filename;
file.addEventListener(ProgressEvent.PROGRESS, function(event:ProgressEvent):void{uploadProgress(event, packageId)} );
file.addEventListener(flash.events.Event.COMPLETE, function(event:flash.events.Event):void{uploadComplete(event, packageId)} );
file.upload(urlRequest, packageId);
} catch (error:Error) {
logging.log(error.message);
}
}
所以我从文件对象的路径中提取文件名。
这些文件来自:
File.applicationStorageDirectory
问题是这不适用于 Windows,因为它们使用反斜杠而不是像 mac osx 那样的斜杠。将文件名和文件分开以使其适用于mac和windows的最佳方法是什么?