3 Simple single-file PHP file upload (file share hosting) script.
5 > :warning: **Security warning**: There is no limit on file size or file type. Please make sure that file permissions are set right so nobody can execute uploaded executables. Or exscape your desired directory! Please skip to server configuration for examples.
12 - [ ] Auto-remove old files
17 Just drop a PHP file in any directory. It will work straight away
21 There are few options that you can change by editing the file itself:
24 - Directory to store uploaded files
28 - Display list uploaded files
32 - Allow users to delete files that they have uploaded (will enable sessions)
34 `allow_deletion` => `true`
38 `listfiles_size` => `true`
42 `listfiles_date` => `true`
44 - Display file dates format
46 `listfiles_date_format` => `'F d Y H:i:s'`
48 - Randomize file names (number of 'false')
50 `random_name_len` => `4`
52 - Keep filetype information (if random name is activated)
54 `random_name_keep_type` => `true`
56 - Random file name letters
58 `random_name_alphabet` => `'qwertyuiopasdfghjklzxcvbnm'`
60 - Display debugging information
62 `debug` => `($_SERVER['SERVER_NAME'] === 'localhost')`
66 - Through an interface:
67 - Choose files via dialogue
68 - Drop files, via HTML5 drag'and'drop (using [dropzone.js](http://www.dropzonejs.com/))
69 - Basic HTML Form (if no JavaScript is suported)
70 - Upload using any compatible tool (like cURL)
72 This example will upload a file and copy URL to clipboard:
75 curl -F "file[]=@file.jpg" strace.club | xclip -sel clip
78 ## Server configuration
80 Do not allow uploaded code execution!
82 ### NGINX configuration example
85 listen 80 default_server;
86 listen [::]:80 default_server ipv6only=on;
88 root /usr/share/nginx;
91 server_name localhost;
94 try_files $uri $uri/ =404;
97 error_page 404 /index.php;
100 fastcgi_split_path_info ^(.+\.php)(/.+)$;
101 fastcgi_pass unix:/var/run/php5-fpm.sock;
102 fastcgi_index index.php;
103 include fastcgi_params;