我正在尝试使用flex程序将文件上传到我的服务器但是没有上传swf文件。所以我尝试上传其他文件类型,如png,jpg,txt,xml和所有这些上传没有问题,但swf不会上传。
MXML文件:
<?xml version="1.0" encoding="utf-8"?>
private function init():void {
urlRequest = new URLRequest(serverSideScript);
fileReferenceList = new FileReferenceList();
fileReferenceList.addEventListener(Event.SELECT, fileSelectedHandler);
}
private function uploadFile():void {
fileReferenceList.browse();
}
private function fileSelectedHandler(event:Event):void {
var fileReference:FileReference;
var fileReferenceList:FileReferenceList = FileReferenceList(event.target);
var fileList:Array = fileReferenceList.fileList;
// get the first file that the user chose
fileReference = FileReference(fileList[0]);
// upload the file to the server side script
fileReference.addEventListener(Event.COMPLETE, uploadCompleteHandler);
fileReference.upload(urlRequest);
// update the status text
statusText.text = "Uploading...";
}
private function uploadCompleteHandler(event:Event):void {
statusText.text = "File Uploaded: " + event.target.name;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Label text="Upload File From Flex to PHP" fontWeight="bold"/>
<s:Label text="Choose a file..." id="statusText"/>
<s:Button click="uploadFile();" label="Upload File"/>
</s:Application>
PHP文件:
<?php
$tempFile = $_FILES['Filedata']['tmp_name'];
$fileName = $_FILES['Filedata']['name'];
$fileSize = $_FILES['Filedata']['size'];
move_uploaded_file($tempFile, "./" . $fileName);
?>
答案 0 :(得分:0)
我明白了,它与flex完全无关。我遇到的问题是php.ini文件中的最大上传大小设置为2mb,我尝试上传的文件是5mb。