File Uploader – Upload without adding to Media Library

HTML

Okay, you’ll of course want to set up an HTML file. I would use this code or something like it:

<form action="upload.php" method="post" enctype="multipart/form-data">
    Select image to upload:
    <input type="file" name="fileToUpload" id="fileToUpload">
    <input type="submit" value="Upload Image" name="submit">
</form>

Of course, you don’t have to use upload.php as your filename, that’s just what w3schools used.

PHP

<?php
$target_dir = "your/file/upload/path";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
    $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
    if($check !== false) {
        echo "File is an image - " . $check["mime"] . ".";
        $uploadOk = 1;
    } else {
        echo "File is not an image.";
        $uploadOk = 0;
    }
}
?>

Change $target_dir to whatever directory you want the files to go into and there you go. There are of course many jQuery plugins to do this in a fancy or pretty way but this is the basics using jQuery.

Other information


Source of information: W3Schools

A great Ajax file uploader script can be found here: http://demo.tutorialzine.com/2013/05/mini-ajax-file-upload-form/

A great jQuery file upload plugin can be found here:
http://blueimp.github.io/jQuery-File-Upload/index.html

According to their website it supports:

File Upload widget with multiple file selection, drag&drop support,
progress bars, validation and preview images, audio and video for
jQuery. Supports cross-domain, chunked and resumable file uploads and
client-side image resizing. Works with any server-side platform (PHP,
Python, Ruby on Rails, Java, Node.js, Go etc.) that supports standard
HTML form file uploads.