Skip to content

Instantly share code, notes, and snippets.

View spoetnik's full-sized avatar

Martijn de Geus spoetnik

  • The Hague, the Netherlands
View GitHub Profile
# @brief
# Performs file upload validation for django. The original version implemented
# by dokterbob had some problems with determining the correct mimetype and
# determining the size of the file uploaded (at least within my Django application
# that is).
# Use it in your models like this;
# validate_file = FileValidator(max_size=24*1024*1024,
# allowed_mimetypes=('text/plain',))
# file = models.FileField(upload_to='path_below_media/%Y/%m/%d', validators=[validate_file])
@spoetnik
spoetnik / form.php
Created April 17, 2018 19:17 — forked from jacmaes/form.php
Processwire: Front-end upload form example using ProcessWire Inputfields #pw
<?php
/**
* Front-end upload form example
* using ProcessWire Inputfields
*/
$sent = false;
$upload_path = $config->paths->assets . "files/.tmp_uploads/";