AIR CODE:
for(var j:int=0;j"e ContenedorListaArchivos.numChildren;j++)
{
var M:MovieClip = MovieClip(ContenedorListaArchivos.getChildAt(j));
if(M.UploadedFile.Estado==1)
{
var file:File = File.desktopDirectory.resolvePath(M.FullPath);
file.addEventListener(ProgressEvent.PROGRESS,M.ProgresoUpload);
file.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA,M.CompleteUpload);
file.upload(new URLRequest(_phpscript+"?Opcion=UploadFile&destination="+_destination));
}
}
PHP CODE:
<?php
tempFile = $_FILES['Filedata']['tmp_name'];
$fileName = $_FILES['Filedata']['name'];
$fileSize = $_FILES['Filedata']['size'];
$dir = ($_GET['destination']) ? $_GET['destination'] : 'images';
if (!file_exists($dir)) mkdir($dir, 0777);
$isMove =move_uploaded_file($tempFile, $dir .'/'. $fileName);
if($isMove)
echo "OK";
else
echo "NO";
?>
when I upload one file the PHP return OK. But, when upload multiple files, only the first copy is "OK", the other returning "NO".
Why? What is wrong in the code? What should I change in the file PHP.ini?
Thank you, best regards.
you loose the homeworks ? Uploading multiple files
<form action="file-upload.php" method="post" enctype="multipart/form-data">
Send these files:<br />
<input name="userfile[]" type="file" /><br />
<input name="userfile[]" type="file" /><br />
<input type="submit" value="Send files" />
</form>
When the above form is submitted, the arrays $_FILES['userfile'], $_FILES['userfile']['name'], and $_FILES['userfile']['size'] will be initialized (as well as in $HTTP_POST_FILES for PHP versions prior to 4.1.0). When register_globals is on, globals for uploaded files are also initialized. Each of these will be a numerically indexed array of the appropriate values for the submitted files.
For instance, assume that the filenames /home/test/review.html and /home/test/xwp.out are submitted. In this case, $_FILES['userfile']['name'][0] would contain the value review.html, and $_FILES['userfile']['name'][1] would contain the value xwp.out. Similarly, $_FILES['userfile']['size'][0] would contain review.html's file size, and so forth.
$_FILES['userfile']['name'][0], $_FILES['userfile']['tmp_name'][0], $_FILES['userfile']['size'][0], and $_FILES['userfile']['type'][0] are also set.
if you are a starter
<?php
function reArrayFiles(&$file_post) {
$file_ary = array();
$file_count = count($file_post['name']);
$file_keys = array_keys($file_post);
for ($i=0; $i<$file_count; $i++) {
foreach ($file_keys as $key) {
$file_ary[$i][$key] = $file_post[$key][$i];
}
}
return $file_ary;
}
if ($_FILES['upload']) {
$file_ary = reArrayFiles($_FILES['userfile']);
foreach ($file_ary as $file) {
print 'File Name: ' . $file['name'];
print 'File Type: ' . $file['type'];
print 'File Size: ' . $file['size'];
}
}
?>