WireUpload (ProcessWire)
Aus Wikizone
Version vom 18. Februar 2019, 12:58 Uhr von 37.49.72.8 (Diskussion) (Die Seite wurde neu angelegt: „Siehe auch ProcessWire Upload Formular Weitere Beispiele <syntaxhighlight lang="php"> </syntaxhighlight> <syntaxhighlight lang="php"> </syntaxhighlight>…“)
Siehe auch
ProcessWire Upload Formular
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;
}