Beispiel #1
0
 /**
  * Carreguem imatges i ho guardem amb el format Format+idEspectacle
  **/
 public function uploadFiles()
 {
     //Si estic carregant la imatge de la configuració per a la web principal
     if (isset($_POST['configuracio'])) {
         $format = $_POST['format'];
         $destination = "";
         if ($format == 'I') {
             $destination = '/Data/Imatges/Agenda.' . pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
         } elseif ($format == 'P') {
             $destination = '/Data/Documents/Agenda.' . pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
         }
         move_uploaded_file($_FILES['file']['tmp_name'], BASEURL . $destination);
         echo json_encode($destination);
         //Altrament, esitc carregant imatges d'espectacles
     } else {
         $idE = $_POST['idEspectacle'];
         $format = $_POST['format'];
         if ($idE == 0) {
             $filename = $format . '0.' . pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
             //Guardem sense extensió... i després la carregarem.
         } else {
             $filename = $format . $idE . '.' . pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
         }
         $destination = BASEURL . '/Data/Imatges/' . $filename;
         $destURL = '/Data/Imatges/' . $filename;
         move_uploaded_file($_FILES['file']['tmp_name'], $destination);
         //Guardo la imatge a l'espectacle corresponent.
         if ($idE > 0) {
             $EM = new EspectaclesModel();
             $EM->updateImatge($idE, $destURL, $format);
         }
         echo $destURL;
     }
 }