salve sto facendo in flash un form x l'upload di file, sto utilizzando uno script di un precedente progetto, che dovrei modificare x qst situazione, utilizzo flash e php, ma in qst file php la destinazione dell'upload è fissa, io vorrei parametrizzarla inviando da flash di volta in volta la destinazione da scegliere
qst è lAs
Codice PHP:
on (release) {
import flash.net.FileReference;
var listener:Object = new Object();
listener.serverfile = 'upload_thumbs.php';
listener.onError = function(file:FileReference, errorString:String) {
trace("Error with: " + file.name + "\nType: " + errorString);
}
listener.onHTTPError =
listener.onIOError =
listener.onSecurityError = function(file:FileReference, errorString:String):Void {
if(errorString == undefined)
errorString = "HTTP or Input Output Error";
this.onError(file, errorString);
}
listener.onCancel = function(file:FileReference):Void {
}
/
listener.onSelect = function(file:FileReference):Void {
trace("onSelect: " + file.name);
if(!file.upload(this.serverfile))
trace("Upload dialog failed to open.");
}
listener.onOpen = function(file:FileReference):Void {
trace("onOpen: " + file.name);
}
listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
var p:Number = new Number(Math.floor(bytesLoaded / bytesTotal * 100));
setProperty("load_clip", _visible, "1");
filenometxt.text=file.name;
filesizetxt.text=file.size+ "byte";
load_clip.loading="File loading: " + String(p) + "%";
load_clip.bar._xscale = String(p);
}
listener.onComplete = function(file:FileReference):Void {
carica();
background_image.gotoAndStop(2);
stato=="send";
function carica(){
thumb=filenometxt.text;
imagePane.contentPath = "./public/projects/thumbs/" + thumb;
imagePane.redraw(true);
_root.uploadBtn.enabled=false;
continua.gotoAndStop(3);
}
report="Upload complete: " + file.name;
}
var filetype:Array = [ {description : "Images (*.jpg, *.jpeg, *.gif, *.png)",
extension : "*.jpg; *.jpeg; *.gif; *.png"}
]
var fileRef:FileReference = new FileReference();
fileRef.addListener(listener);
fileRef.browse(filetype);
}
e qst è il file php
Codice PHP:
<?php // 4, compatibile 5.0 e 5.1
// Directory di destinazione
$destination_dir = './public/projects/thumbs/';
// Verifico che il file sia valido e come lui tutte le informazioni
// Controllo inoltre che non ci siano errori nell' invio ... altrimenti
// non faccio niente
if(
// esiste il file di nome Filedata ?
isset($_FILES['Filedata']) &&
// é un array ?
is_array($_FILES['Filedata']) &&
// esistono gli elementi tmp_name, name, size, error
// di questo array ?
isset(
$_FILES['Filedata']['tmp_name'],
$_FILES['Filedata']['name'],
$_FILES['Filedata']['size'],
$_FILES['Filedata']['error']
) &&
// l' errore é esattamente zero ?
intVal($_FILES['Filedata']['error']) === 0
) {
//$immname= rand(0,1000)."_".$_FILES['Filedata']['name'];
// operazione di spostamento da temporanea ad altra cartella
// se riesco a spostare il file sulla destinazione scrivo un tipo di output
//if(move_uploaded_file($_FILES['Filedata']['tmp_name'], $destination_dir.$_FILES['Filedata']['name'])) {
if(move_uploaded_file($_FILES['Filedata']['tmp_name'], $destination_dir.$_FILES['Filedata']['name'])) {
// $result = "&result=".$_FILES['Filedata']['name']."&";
//$result = "&result=".$immname."&";
}
}
?>
vorrei che $destination_dir sia parametrizzata
mi scuso in anticipo se ho sbagliato sezione, ma siccome riguarda anche flash ho pensato fosse indifferente
grazie