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 6206073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:23:04+00:00 2026-05-24T05:23:04+00:00

I am writing a file management application in Perl, PHP, and JavaScript (jQuery) and

  • 0

I am writing a file management application in Perl, PHP, and JavaScript (jQuery) and I would like to give the user the ability to cancel their upload.

Here’s some background infos:
When the user chooses to upload a file, I change the target of the form to an iFrame, which posts to the perl script. Within the script, I update a row in the database that shows the current status of the upload. The status could be success, error, initializing, abort, or expired. When the status is abort, I would like to stop the upload completely.

Is there a way to kill off this script from within the hook? (So that I don’t have to wait for the whole file.) On a side note, the -e $filepath works, but it still loops through the whole file, so the message won’t display until afterwards. In either case, I would just like the script to completely stop.

Added some more code:

Perl:

my $cgi = CGI->new(\&hook, \%data, 0);

sub hook { 
    my $status = GetStatus();

    if(-e $$data{filepath} and $status eq "initializing"){
        # send JSON back to browser
        # insert your amazing snippet here
        ... 
    }

    if($status eq "success"){
        # continue writing file to disk
        # update db
        ... 
    }

    if($status eq "abort"){
        # cancel the upload
        # insert your amazing snippet here
        ... 
    }

} 

HTML:

<iframe id="upload_target" onload="uploadDone();"></iframe>

jQuery:

$('#upload_form').submit(function(data){
    window.setInterval('doProgress()', 250);
});

function doProgress() {
    $.ajax({
        ...
        success: function(data){
            json = $.parseJSON(data);
            if(json.status != null){
                // json.message contains the percentage number
                $("#progressbar").reportprogress(json.message);
            }
        }
    });
}

function uploadDone() { 
    var ret = $('#upload_target').contents().find('body').text();
    var json = jQuery.parseJSON(ret);

    if(json.status != null){
        $.modal.close();
        show_message(json);
    }
}

Edit:
I saw somewhere on Google that aborting the request through javascript might be the way to solve the problem. Can anyone say for sure whether this is true? What it entails is simply assigning the request to a variable, then calling the abort() method on it, ex: xhr.abort();

  • 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-05-24T05:23:04+00:00Added an answer on May 24, 2026 at 5:23 am

    I don’t know without sourcediving exactly how CGI is handling the upload and calling the hook function, but my first attempt to stop the upload would be to close STDIN.

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

Sidebar

Related Questions

Often when writing file writers or parsers in c++, I would like to monitor
I'm writing a custom file selection component. In my UI, first the user clicks
I would like to store some Application-Related Metadata for Files, and NTFS Alternate Data
I'm writing a Content Management System in PHP, and I want it to be
I'm writing Content Management software in PHP (which should not be bigger then 3kb
I am writing an application to manage user access to files. The short version
Background I am writing and using a very simple CGI-based (Perl) content management tool
I'm writing a server management application. I want to show a and a grid
I find myself writing file and directory utility functions all the time, and I
While writing a file using ofstream, how do I know when the file's size

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.