]> git.mxchange.org Git - simple-upload.git/blob - README.md
:memo: Added server config example
[simple-upload.git] / README.md
1 # Simple PHP upload
2
3 Simple single-file PHP file upload (file share hosting) script.
4
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.
6
7 ## Installation
8
9 Just drop a PHP file in any directory. It will work straight away
10
11 ## Configuration
12
13 There are few options that you can change by editing the file itself:
14
15
16
17 - Directory to store uploaded files
18
19         `uploaddir` => `'.'`
20
21 - Display list uploaded files
22
23         `listfiles` => `true`
24
25 - Allow users to delete files that they have uploaded (will enable sessions)
26
27         `allow_deletion` => `true`
28
29 - Display file sizes
30
31         `listfiles_size` => `true`
32
33 - Display file dates
34
35         `listfiles_date` => `true`
36
37 - Display file dates format
38
39         `listfiles_date_format` => `'F d Y H:i:s'`
40
41 - Randomize file names (number of 'false')
42
43         `random_name_len` => `4`
44
45 - Keep filetype information (if random name is activated)
46
47         `random_name_keep_type` => `true`
48
49 - Random file name letters
50
51         `random_name_alphabet` => `'qwertyuiopasdfghjklzxcvbnm'`
52
53 - Display debugging information
54
55         `debug` => `($_SERVER['SERVER_NAME'] === 'localhost')`
56
57 ## Usage options
58
59 - Through an interface:
60         - Choose files via dialogue
61         - Drop files, via HTML5 drag'and'drop (using [dropzone.js](http://www.dropzonejs.com/))
62         - Basic HTML Form (if no JavaScript is suported)
63 - Upload using any compatible tool (like cURL)
64
65         This example will upload a file and copy URL to clipboard:
66
67         ```bash
68         curl -F "file=@file.jpg" your-host/sharing/ | xclip -sel clip
69         ```
70
71 ## Server configuration
72
73 Do not allow uploaded code execution!
74
75 ### NGINX configuration example
76
77         server {
78                 listen 80 default_server;
79                 listen [::]:80 default_server ipv6only=on;
80
81                 root /usr/share/nginx;
82                 index index.php;
83
84                 server_name localhost;
85
86                 location / {
87                         try_files $uri $uri/ =404;
88                 }
89
90                 error_page 404 /index.php;
91
92                 location /index.php {
93                         fastcgi_split_path_info ^(.+\.php)(/.+)$;
94                         fastcgi_pass unix:/var/run/php5-fpm.sock;
95                         fastcgi_index index.php;
96                         include fastcgi_params;
97                 }
98         }