Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8291235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:03:34+00:00 2026-06-08T13:03:34+00:00

I am trying to code my own simple AJAX image upload script via jQuery.

  • 0

I am trying to code my own simple AJAX image upload script via jQuery. I have found some plugins but they are way too customized for what’s needed, and I cannot get any of them working properly.

I just want to somehow detect when the user drags and drops an image onto the page. From there I’m sure it’s not hard to upload that data and move into a /cache/ directory and allow for further options..

but right now I’m totally stuck with the drag/drop functionality. Literally no idea how I should approach this. What kind of event handler is needed? Will I need to custom code my own event handler? Any advice would be more than appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T13:03:35+00:00Added an answer on June 8, 2026 at 1:03 pm

    What kind of event handler is needed?

    Drag’n’drop requires a HTML5 browser – but that’s pretty much all of them now.

    I’d recommend not starting from scratch as there’s quite a bit of code needed – I quite like this wrapper that implements it as a jQuery plugin.

    http://www.github.com/weixiyen/jquery-filedrop

    After defining an element in the document with class div, you can initialise it to accept dropped files with:

    function fileSetUploadPercent(percent, divID){
    
        var uploadString = "Uploaded " + percent + " %";
    
        $('#'.divID).text(uploadString);
    }
    function fileUploadStarted(index, file, files_count){
    
        var divID = getDivID(index, file);
    
        createFileUploadDiv(divID);     //create the div that will hold the upload status
    
        fileSetUploadPercent(0, divID); //set the upload status to be 0
    }
    
    function  fileUploadUpdate(index, file, currentProgress){
    
        //Logger.log("fileUploadUpdate(index, file, currentProgress)");
    
        var string = "index = " + index + " Uploading file " + file.fileName + " size is " + file.fileSize + " Progress = " + currentProgress;
        $('#status').text(string);
    
        var divID = getDivID(index, file);
        fileSetUploadPercent(currentProgress, divID);
    }
    
    function fileUploadFinished(index, file, json, timeDiff){
    
        var divID = getDivID(index, file);
        fileSetUploadPercent(100, divID);
    
        if(json.status == "OK"){
            createThumbnailDiv(index, file, json.url, json.thumbnailURL);
        }
    }
    
    
    
    function    fileDocOver(event){
        $('#fileDropTarget').css('border', '2px dashed #000000').text("Drop files here");
    }
    $(".fileDrop").filedrop({
    
                fallback_id: 'fallbackFileDrop',
                url: '/api/upload.php',
                //    refresh: 1000,
                paramname: 'fileUpload',
                //    maxfiles: 25,           // Ignored if queuefiles is set > 0
                maxfilesize: 4,         // MB file size limit
                //    queuefiles: 0,          // Max files before queueing (for large volume uploads)
                //    queuewait: 200,         // Queue wait time if full
                //    data: {},
                //    headers: {},
                //    drop: empty,
                //    dragEnter: empty,
                //    dragOver: empty,
                //    dragLeave: empty,
                //    docEnter: empty,
                docOver: fileDocOver,
            //  docLeave: fileDocLeave,
                //  beforeEach: empty,
                //   afterAll: empty,
                //  rename: empty,
                //  error: function(err, file, i) {
                //    alert(err);
                //  },
                uploadStarted: fileUploadStarted,
                uploadFinished: fileUploadFinished,
                progressUpdated: fileUploadUpdate,
                //     speedUpdated
            });
    

    The bit of the web page that accepts uploads has this HTML.

    <div class='fileDrop'>
    Upload a file by dragging it.
    <span id='fileDropTarget'/>
    
    </div>
    

    The file drop works on the outer <div> but it’s nice to make a nice big target that says ‘DROP HERE’ so that users aren’t confused about where they need to drop the file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement my own memory allocation code which is simple yet
I have made my own simple widget by deriving from QWidget, and am trying
i am trying to learn building own jquery plugin . with the simple example
I'm trying to figure what a simple jQuery code is to fade in an
I am trying to execute a binary wrapped inside my own assembly code, there
I'm trying to write a code library for my own personal use and I'm
I´m trying to code a tooltip (Yes I know, I have my reasons to
i have a simple statement of code that reads: Return String.Format({0} {1} {2}, _var1,
Simple situation. I'm trying to write my own blog with a minor twist. Part
I've been trying to get my own opinion about this issue but could not,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.