SlideShare a Scribd company logo
File upload 
for the 21st century 
@jiripudil 
#posobota
Upload, anyone?
RFC 1867 
Form-based File Upload in HTML 
published 1995
RFC 1867 
<form enctype="multipart/form-data" 
method="post"> 
<input type="file">
Uploading in Nette 
$form->addUpload('file', 'File');
Uploading in Nette 
$form->addUpload('file', 'File') 
->addCondition($form::FILLED) 
->addRule($form::MAX_FILE_SIZE, 
NULL, 1024) 
->addRule($form::IMAGE);
Uploading in Nette 
public function process($form, $values) { 
/** @var FileUpload $file */ 
$file = $values->file; 
}
Uploading multiple files 
$form->addUpload('file1', 'File 1'); 
$form->addUpload('file2', 'File 2'); 
$form->addUpload('file3', 'File 3'); 
// ... 
$form->addUpload('file100', 'File 100');
Uploading multiple files
Uploading multiple files 
for ($i = 1; $i <= 100; $i++) { 
$form->addUpload("file$i", "File $i"); 
}
Uploading multiple files
Uploading multiple files
Uploading multiple files 
$form->addUpload('files', 'Files', TRUE); 
// or (nette/forms@master) 
$form->addMultiUpload('files', 'Files');
Uploading multiple files 
<input type="file" multiple>
Uploading multiple files 
public function process($form, $values) { 
/** @var FileUpload[] $files */ 
$files = $values->files; 
}
File upload for the 21st century
File upload for the 21st century
File upload for the 21st century
File upload for the 21st century
File upload for the 21st century
File upload for the 21st century
Asynchronous upload 
var data = new FormData(form); 
var xhr = new XMLHttpRequest; 
xhr.open('POST', form.action); 
xhr.onreadystatechange = function (e) { 
if (xhr.readyState === 4) { // DONE 
if (xhr.status === 200) {} else {} 
} 
};
Progress tracking 
xhr.upload.onprogress = function (e) { 
if (e.lengthComputable) { 
var percentage = e.loaded / e.total; 
// display somewhere 
} 
}; 
xhr.send(data);
File upload for the 21st century
Drag'n'drop 
$('#dropzone').on('dragenter dragover', fn (e) 
{ 
if (%containsFiles%) { 
e.preventDefault(); 
} 
});
Drag'n'drop 
%containsFiles%: 
// FF, IE - types is 'DOMStringList' 
e.dataTransfer.types.contains('Files'); 
// WebKit - types is Array 
e.dataTransfer.types.indexOf('Files') > -1;
Drag'n'drop 
$('#dropzone').on('drop', function (e) { 
e.preventDefault(); 
var data = new FormData(); 
var files = e.dataTransfer.files; 
for (var i = 0; i < files.length; i++) { 
data.append(files[i].name, 
files[i]); 
} 
});
File upload for the 21st century
File upload for the 21st century
What happens on the server side
What happens on the server side
What happens on the server side
File upload for the 21st century
Upload Module
What upload module does
Installation 
$ git clone -b 2.2 
https://github.com/vkholodkov/nginx-upload-module
Installation 
$ ./configure 
--add-module=/path/to/upload/module
Configuration 
client_max_body_size 32m; 
location /upload { 
upload_pass @upload; 
# ... 
} 
location @upload { 
rewrite ^ index.php last; 
}
Configuration 
upload_store /tmp/upload 1; 
upload_store_access user:r group:r; 
upload_cleanup 400 404 499 500-505; 
upload_max_file_size 8m; 
upload_limit_rate 512k;
Configuration 
upload_set_form_field 
$upload_field_name[name] "$upload_file_name"; 
-"-[path] "$upload_file_path"; 
-"-[type] "$upload_content_type"; 
upload_aggregate_form_field 
-"-[size] "$upload_file_size"; 
-"-[md5] "$upload_file_md5"; 
upload_pass_form_field "submit";
Configuration 
upload_set_form_field 
$upload_field_name[$upload_file_number][name] 
"$upload_file_name"; 
upload_tame_arrays on;
Summary
File upload for the 21st century
File upload for the 21st century
File upload for the 21st century
Thanks! 
@jiripudil 
#posobota

More Related Content

PDF
File system
XLS
Up.Php
PPTX
Image upload in php MySql
PPTX
Uploading a file with php
ODP
Php File Upload
PPT
PHP file
PPTX
File Uploading in PHP
PPT
File Upload
File system
Up.Php
Image upload in php MySql
Uploading a file with php
Php File Upload
PHP file
File Uploading in PHP
File Upload

What's hot (17)

PDF
Php file handling in Hindi
PPTX
Ch3(working with file)
DOCX
Exmaples of file handling
PPTX
File upload php
PPTX
Php File Operations
PPT
php file uploading
PPTX
Basics of Unix Adminisration
PPT
Php i basic chapter 4
PPT
PHP - Introduction to File Handling with PHP
ODT
Huong dan cai dat hadoop
PDF
The love child of Android and .NET: App development with Xamarin
PDF
C A S Sample Php
DOCX
Zotero Part1
PPTX
Introduction of file handling
PDF
Laporan setting dns
PDF
Mengembalikan data yang terhapus atau rusak pada hardisk menggunakan ubuntu
Php file handling in Hindi
Ch3(working with file)
Exmaples of file handling
File upload php
Php File Operations
php file uploading
Basics of Unix Adminisration
Php i basic chapter 4
PHP - Introduction to File Handling with PHP
Huong dan cai dat hadoop
The love child of Android and .NET: App development with Xamarin
C A S Sample Php
Zotero Part1
Introduction of file handling
Laporan setting dns
Mengembalikan data yang terhapus atau rusak pada hardisk menggunakan ubuntu
Ad

Similar to File upload for the 21st century (9)

PDF
Php File Upload
PDF
Real World Seaside Applications
PPTX
lecture 11.pptx
PDF
Drag and drop file upload with Dropzone in CodeIgniter
PPTX
PHP fundamnetal in information technology CHapter -02.pptx
PPTX
Implementing a Fileserver with Nginx and Lua
PPT
Frontend Servers and NGINX: What, Where and How
PDF
Large Files without the Trials
PDF
Introduction to php web programming - get and post
Php File Upload
Real World Seaside Applications
lecture 11.pptx
Drag and drop file upload with Dropzone in CodeIgniter
PHP fundamnetal in information technology CHapter -02.pptx
Implementing a Fileserver with Nginx and Lua
Frontend Servers and NGINX: What, Where and How
Large Files without the Trials
Introduction to php web programming - get and post
Ad

Recently uploaded (20)

PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
Transform Your Business with a Software ERP System
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PDF
Cost to Outsource Software Development in 2025
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Digital Systems & Binary Numbers (comprehensive )
PPTX
Computer Software and OS of computer science of grade 11.pptx
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
Understanding Forklifts - TECH EHS Solution
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PPTX
L1 - Introduction to python Backend.pptx
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Design an Analysis of Algorithms I-SECS-1021-03
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Transform Your Business with a Software ERP System
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Cost to Outsource Software Development in 2025
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Odoo POS Development Services by CandidRoot Solutions
Which alternative to Crystal Reports is best for small or large businesses.pdf
Digital Systems & Binary Numbers (comprehensive )
Computer Software and OS of computer science of grade 11.pptx
Why Generative AI is the Future of Content, Code & Creativity?
Understanding Forklifts - TECH EHS Solution
iTop VPN Free 5.6.0.5262 Crack latest version 2025
L1 - Introduction to python Backend.pptx
Navsoft: AI-Powered Business Solutions & Custom Software Development
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Designing Intelligence for the Shop Floor.pdf
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool

File upload for the 21st century