ProcessWire - Uploads: Unterschied zwischen den Versionen

Aus Wikizone
Wechseln zu: Navigation, Suche
Zeile 3: Zeile 3:
 
Im Backend auf Array stellen und auf pdf einschränken. Im Template.
 
Im Backend auf Array stellen und auf pdf einschränken. Im Template.
 
<syntaxhighlight lang="php">
 
<syntaxhighlight lang="php">
// check for file_upload
+
// Backend Field Name is file_upload
 
$fileUploadMarkup = '';
 
$fileUploadMarkup = '';
 
$nFiles = count($page->file_upload);
 
$nFiles = count($page->file_upload);
Zeile 18: Zeile 18:
 
}$fileUploadMarkup = "<div class='fileUploads' style='margin-bottom:4px;'>$fileUploadMarkup</div>";
 
}$fileUploadMarkup = "<div class='fileUploads' style='margin-bottom:4px;'>$fileUploadMarkup</div>";
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 
== Frontend Uploads ==
 
== Frontend Uploads ==
 
https://processwire.com/talk/topic/206-renaming-uploaded-files-from-tmp_name/#entry1371%C2%A0
 
https://processwire.com/talk/topic/206-renaming-uploaded-files-from-tmp_name/#entry1371%C2%A0

Version vom 23. Mai 2017, 11:39 Uhr

Backend Uploads

PDF Dateien zum Download anbieten

Im Backend auf Array stellen und auf pdf einschränken. Im Template.

// Backend Field Name is file_upload
$fileUploadMarkup = '';
$nFiles = count($page->file_upload);
if($nFiles){
	foreach ($page->file_upload as $file) {
		$fileUrl = $file->httpUrl;
		$fileName = ($file->description) ? $file->description : $file->name;
		$fileSize = $file->filesizeStr;
		$fileUploadMarkup .= "
		<div class='file'>
			<i style='color: #a91e1e;' class='fa fa-file-pdf-o' aria-hidden='true'></i> <a href='$fileUrl' target='_blank'>$fileName</a> ($fileSize)
		</div>";
	}
}$fileUploadMarkup = "<div class='fileUploads' style='margin-bottom:4px;'>$fileUploadMarkup</div>";

Frontend Uploads

https://processwire.com/talk/topic/206-renaming-uploaded-files-from-tmp_name/#entry1371%C2%A0