<?php

require_once "xml2json.php";
$file = utf16_to_utf8(file_get_contents($_FILES['file']['tmp_name']));
$log = fopen("log.txt", "a");
// fwrite($log, "starting\n");
// fwrite($log, "##" . $_FILES['file']['name'] . "##\n");
if (isPlist($_FILES['file']['name'])) {
    // fwrite($log, "is a plist\n");
    $postArgs = addFilenameAndType(xml2json::transformXmlStringToJson($file), $_FILES['file']['name'], "plist");
} else {
    if (isStrings($_FILES['file']['name'])) {
        // fwrite($log, "is a strings\n");
        $postArgs = transformStringsToJson($file, $_FILES['file']['name']);
    } else {
        if (isZip($_FILES['file']['name'])) {
            // fwrite($log, "is a zip\n");
            $postArgs = archiveToJson($file, $log);
        }
    }
}
fclose($log);
header("Content-Type: text/json");
// temporary fix
echo $postArgs;
function archiveToJson($zipFileContents, $log)
{
    $aFileName = "tmpArchive" . time() . ".zip";
    $theFile = fopen($aFileName, "w");
    // fwrite($log, "opened archive\n");
    fwrite($theFile, $zipFileContents);
Exemple #2
0
$groupName = uniqid('_' . $fileName . '_');
$uploaddir = $rootFolder . $groupName;
/* create subfolder if it does not exist */
if (!is_dir($uploaddir)) {
    mkdir($uploaddir);
}
/* move uploaded files from tmp to destination */
for ($i = 0; $i < count($files['name']); $i++) {
    /* Get the tmp file path */
    $tmpFilePath = $files['tmp_name'][$i];
    if ($tmpFilePath != "") {
        $newFilePath = $uploaddir . "/" . $files['name'][$i];
        /* move */
        if (move_uploaded_file($tmpFilePath, $newFilePath)) {
            /* handle zip files */
            if (isZip($newFilePath)) {
                unzip($newFilePath);
            }
        }
    }
}
/* GET FOLDERS */
$folders = getFolders($uploaddir);
$group = getGroupFolder($fileName, $fileDescription);
$files = getFiles($uploaddir);
/* DB - ADD FILES TO FOLDER */
foreach ($files as $file) {
    //echo "File: ".$file->getBasename()." in ".$file->getPath()."<br />";
    $fDescr = "Size: " . round($file->getSize() / 1024, 2) . " Kb.";
    $baseFolder = str_replace($uploaddir, "", $file->getPath());
    //echo "BASE: ".$baseFolder.' #### ';