WireUpload (ProcessWire): Unterschied zwischen den Versionen

Aus Wikizone
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: „Siehe auch ProcessWire Upload Formular Weitere Beispiele <syntaxhighlight lang="php"> </syntaxhighlight> <syntaxhighlight lang="php"> </syntaxhighlight>…“)
 
 
Zeile 1: Zeile 1:
 
Siehe auch
 
Siehe auch
 
  [[ProcessWire Upload Formular]]
 
  [[ProcessWire Upload Formular]]
 +
https://processwire.com/api/ref/wire-upload/
  
 
Weitere Beispiele
 
Weitere Beispiele

Aktuelle Version vom 5. August 2024, 20:20 Uhr

Siehe auch

ProcessWire Upload Formular
https://processwire.com/api/ref/wire-upload/

Weitere Beispiele

/**
  * Process a module upload 
  *
  * @param string $inputName Optionally specify the name of the $_FILES input to look for (default=upload_module)
  * @param string $destinationDir Optionally specify destination path for completed unzipped files
  * @return bool|string Returns destinationDir on success, false on failure.
  *
  */
 public function uploadModule($inputName = 'upload_module', $destinationDir = '')
 {
     if (!$this->canUploadDownload()) {
         $this->error($this->_('Unable to complete upload'));
         return false;
     }
     $tempDir = $this->getTempDir();
     $ul = new WireUpload($inputName);
     $ul->setValidExtensions(array('zip'));
     $ul->setMaxFiles(1);
     $ul->setOverwrite(true);
     $ul->setDestinationPath($tempDir);
     $ul->setExtractArchives(false);
     $ul->setLowercase(false);
     $files = $ul->execute();
     if (count($files)) {
         $file = $tempDir . reset($files);
         $destinationDir = $this->unzipModule($file, $destinationDir);
         if ($destinationDir) {
             $this->modules->resetCache();
         }
     } else {
         $this->error($this->_('No uploads found'));
         $destinationDir = false;
     }
     return $destinationDir;
 }