Here is the PHP script i threw together...
<?php
$uploadto = "/home/mysite/www/images/user_uploaded/flash_test";
$tmp_name = $_FILES["file"]["tmp_name"];
$name = $uploadto . $_FILES["file"]["name"];
move_uploaded_file($tmp_name, $name);
/* also tried... from Flash help file
$MAXIMUM_FILESIZE = 1024 * 200; // 200KB
$MAXIMUM_FILE_COUNT = 10; // keep maximum 10 files on server
$uploadtotmp = "/home/mysite/www/images/user_uploaded/flash_test/temp/";
$uploadto = "/home/mysite/www/images/user_uploaded/flash_test/";
echo exif_imagetype($_FILES['Filedata']);
if ($_FILES['Filedata']['size'] <= $MAXIMUM_FILESIZE) {
move_uploaded_file($_FILES['Filedata']['tmp_name'], $uploadtotmp.$_FILES['Filedata']['name']);
$type = exif_imagetype("./temporary/".$_FILES['Filedata']['name']);
if ($type == 1 || $type == 2 || $type == 3) {
rename($uploadtotmp.$_FILES['Filedata']['name'], $uploadto.$_FILES['Filedata']['name']);
} else {
unlink($uploadtotmp.$_FILES['Filedata']['name']);
}
}
$directory = opendir($uploadto);
$files = array();
while ($file = readdir($directory)) {
array_push($files, array($uploadto.$file, filectime($uploadto.$file)));
}
usort($files, sorter);
if (count($files) > $MAXIMUM_FILE_COUNT) {
$files_to_delete = array_splice($files, 0, count($files) - $MAXIMUM_FILE_COUNT);
for ($i = 0; $i < count($files_to_delete); $i++) {
unlink($files_to_delete[$i][0]);
}
}
print_r($files);
closedir($directory);
function sorter($a, $b) {
if ($a[1] == $b[1]) {
return 0;
} else {
return ($a[1] < $b[1]) ? -1 : 1;
}
}
AND.... from php.net
// Take the Files Selected by the user and upload them to the server.
$uploadto = "/home/mysite/www/images/user_uploaded/flash_test/";
foreach ($_FILES["file"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["file"]["tmp_name"][$key];
$name = $_FILES["file"]["name"][$key];
$path = $uploadto . $name;
move_uploaded_file($tmp_name, $path);
echo "File Uploaded: " . $path . "<br>";
}
}
*/
?>
In the ActionScript i changed...
Line 3:
System.security.allowDomain ("http://www.mysite.com");
Line 76: (of the .AS file that is imported in the .fla)
file.upload("http://www.mysite.com/flash_test/uploader.php");
The results i am getting are troubling at this hour 🙂.
The .swf is showing that files are getting uploaded, but in my image directory nothing is showing up!! so why are the files not being uploaded to my dir?
help is appreciated. Thanks.