Esempio n. 1
0
    $exiftool->getXMPdata($uploaded_file);
    $metadatas = $exiftool->getMetadata($uploaded_file);
    /* $data = array(array("SourceFile" => "{$metadatas[0]["SourceFile"]}",
           "XMP:Title" => "image",
           "XMP:Rights" => "image",
           "XMP:Creator" => "image",
           "XMP:City" => "image",
           "XMP:Country" => "image",
           "IPTC:Credit" => "image",
           "IPTC:Source" => "image"
       ));
       file_put_contents('../data/tmp.json', json_encode($data));
       $exiftool->setMetadata($uploaded_file,"../data/tmp.json");*/
    $model = new FileModel(pathinfo(basename($uploaded_file))['filename'] . ".json", "../data/");
    $metas = $exiftool->getMetadata($uploaded_file);
    $model->saveToFile($metas);
    $img = array('name' => $metas[0]["XMP"]["Title"], 'creator' => $metas[0]['XMP']["Creator"], 'filename' => pathinfo(basename($uploaded_file))['filename'], 'url' => "app/uploads/" . $metas[0]["File"]["FileName"]);
    append_to_file(json_encode($img), "../../images.json");
}
function append_to_file($data = array(), $file)
{
    if (file_exists($file)) {
        $inp = file_get_contents($file);
        $tempArray = json_decode($inp, true);
        if (isset($tempArray) && !empty($tempArray)) {
            array_push($tempArray, $data);
        } else {
            $tempArray = [$data];
        }
        $jsonData = json_encode($tempArray);
        file_put_contents($file, $jsonData);
 public function uploadAction()
 {
     $uploaded_file = $this->uploader->upload();
     if (isset($uploaded_file)) {
         $this->exiftool->getXMPdata($uploaded_file);
         $metadatas = $this->exiftool->getMetadata($uploaded_file);
         $data = array(array("SourceFile" => "{$metadatas[0]["SourceFile"]}", "XMP:Title" => "image", "XMP:Rights" => "image", "XMP:Creator" => "image", "XMP:City" => "image", "XMP:Country" => "image", "IPTC:Credit" => "image", "IPTC:Source" => "image"));
         file_put_contents('app/data/tmp.json', json_encode($data));
         $this->exiftool->setMetadata($uploaded_file, "app/data/tmp.json");
         $model = new FileModel(pathinfo(basename($uploaded_file))['filename'] . ".json", "app/data/");
         $model->saveToFile($this->exiftool->getMetadata($uploaded_file));
         return $this->homeAction();
         //header('Location: http://127.0.0.1:82/projects/MVCProject/');
         //die();
     } else {
     }
 }