Shouldn't this work?
i want upload files in folder on server user selected in combobox. cant working, ideas?
in flex:
private function startupload():void {
if (_arruploadfiles.length > 0) {
disableui();
listfiles.selectedindex = _numcurrentupload;
scrollfiles();
// variables send along upload
var sendvars:urlvariables = new urlvariables();
sendvars.projekt = combobox(projektnamn).selecteditem.data;
var request:urlrequest = new urlrequest();
request.data = sendvars;
request.url = _struploadurl;
request.method = urlrequestmethod.post;
_refuploadfile = new filereference();
_refuploadfile = listfiles.selecteditem.file;
_refuploadfile.addeventlistener(progressevent.progress, onuploadprogress);
_refuploadfile.addeventlistener(event.complete, onuploadcomplete);
_refuploadfile.addeventlistener(ioerrorevent.io_error, onuploadioerror);
_refuploadfile.addeventlistener(securityerrorevent.security_error, onuploadsecurityerror);
_refuploadfile.upload(request, "file", false);
}
}
this in upload.php:
$file_path = $_server['document_root']."/mockingbird/".$_request['projekt'];
$file_temp = $_files['file']['tmp_name'];
$file_name = $_files['file']['name'];
//checks duplicate files
if (!file_exists($file_path."/".$file_name)) {
//complete upload
$filestatus = move_uploaded_file($file_temp,$file_path."/".$file_name);
if(!$filestatus) {
$success = "false";
array_push($errors,"upload failed. please try again.");
}
}
else {
$success = "false";
array_push($errors,"file exists on server.");
}
break;
default:
$success = "false";
array_push($errors,"no action requested.");
}
return_result($success,$errors,$data);
in flex:
private function startupload():void {
if (_arruploadfiles.length > 0) {
disableui();
listfiles.selectedindex = _numcurrentupload;
scrollfiles();
// variables send along upload
var sendvars:urlvariables = new urlvariables();
sendvars.projekt = combobox(projektnamn).selecteditem.data;
var request:urlrequest = new urlrequest();
request.data = sendvars;
request.url = _struploadurl;
request.method = urlrequestmethod.post;
_refuploadfile = new filereference();
_refuploadfile = listfiles.selecteditem.file;
_refuploadfile.addeventlistener(progressevent.progress, onuploadprogress);
_refuploadfile.addeventlistener(event.complete, onuploadcomplete);
_refuploadfile.addeventlistener(ioerrorevent.io_error, onuploadioerror);
_refuploadfile.addeventlistener(securityerrorevent.security_error, onuploadsecurityerror);
_refuploadfile.upload(request, "file", false);
}
}
this in upload.php:
$file_path = $_server['document_root']."/mockingbird/".$_request['projekt'];
$file_temp = $_files['file']['tmp_name'];
$file_name = $_files['file']['name'];
//checks duplicate files
if (!file_exists($file_path."/".$file_name)) {
//complete upload
$filestatus = move_uploaded_file($file_temp,$file_path."/".$file_name);
if(!$filestatus) {
$success = "false";
array_push($errors,"upload failed. please try again.");
}
}
else {
$success = "false";
array_push($errors,"file exists on server.");
}
break;
default:
$success = "false";
array_push($errors,"no action requested.");
}
return_result($success,$errors,$data);
More discussions in Flex (Read Only)
adobe
Comments
Post a Comment