Giter VIP home page Giter VIP logo

simple-php-upload's Introduction

Simple PHP upload

Simple single-file PHP file upload (file share hosting) script.

โš ๏ธ 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 code. See server configuration for examples.

TODO

  • Delete files
  • Private files
  • Sort by age
  • Auto-remove old files
  • AJAX Uploader

Installation

Just drop a PHP file in any directory. It will work straight away

Configuration

There are few options that you can change by editing the file itself:

  • Directory to store uploaded files

    uploaddir => '.'

  • Display list uploaded files

    listfiles => true

  • Allow users to delete files that they have uploaded (will enable sessions)

    allow_deletion => true

  • Display file sizes

    listfiles_size => true

  • Display file dates

    listfiles_date => true

  • Display file dates format

    listfiles_date_format => 'F d Y H:i:s'

  • Randomize file names (number of 'false')

    random_name_len => 4

  • Keep filetype information (if random name is activated)

    random_name_keep_type => true

  • Random file name letters

    random_name_alphabet => 'qwertyuiopasdfghjklzxcvbnm'

  • Display debugging information

    debug => ($_SERVER['SERVER_NAME'] === 'localhost')

Usage options

  • Through an interface:

    • Choose files via dialogue
    • Drop files, via HTML5 drag'and'drop (using dropzone.js)
    • Basic HTML Form (if no JavaScript is suported)
  • Upload using any compatible tool (like cURL)

    This example will upload a file and copy URL to clipboard:

     curl -F "file[][email protected]" strace.club | xclip -sel clip

Server configuration

Do not allow uploaded code execution!

NGINX configuration example

Edit the NGINX configuration file (/etc/nginx/sites-enabled/fileuploader):

server {
	listen 80 default_server;
	listen [::]:80 default_server ipv6only=on;

	root /usr/share/nginx;
	index index.php;

	server_name localhost;

	location / {
		try_files $uri $uri/ =404;
	}

	error_page 404 /index.php;

	location /index.php {
		fastcgi_split_path_info ^(.+\.php)(/.+)$;
		fastcgi_pass unix:/var/run/php5-fpm.sock;
		fastcgi_index index.php;
		include fastcgi_params;
	}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.