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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:31:59+00:00 2026-06-03T23:31:59+00:00

Am stuck here. I’ve been trying to upload some photos and at the same

  • 0

Am stuck here. I’ve been trying to upload some photos and at the same time pass the id of the album (value is in a hidden form in the form) to the same php script that processes the upload. but i dont know how to pass the album id seprately this is the code.

Js

input.addEventListener("change", function (evt) {
        document.getElementById("response").innerHTML = "<img src='../assets/admin/images/loading.gif' />"
        var i = 0, len = this.files.length, img, reader, file;

    for ( ; i < len; i++ ) {
        file = this.files[i];

        if (!!file.type.match(/image.*/)) {
            if ( window.FileReader ) {
                reader = new FileReader();
                reader.onloadend = function (e) { 
                    showUploadedItem(e.target.result, file.fileName);
                };
                reader.readAsDataURL(file);
            }
            if (formdata) {
                formdata.append("images[]", file);
            }
        }   
    }

    if (formdata) {
        $.ajax({
            url: "../assets/admin/ajaxupload/upload.php",
            type: "POST",
            data: formdata,
            processData: false,
            contentType: false,
            success: function (res) {
                document.getElementById("response").innerHTML = res; 
            }
        });
    }

PHP

//how do i retrieve the given album id value that was passed.

foreach ($_FILES["images"]["error"] as $key => $error) {
    if ($error == UPLOAD_ERR_OK) {
        $name = $_FILES["images"]["name"][$key];
        move_uploaded_file( $_FILES["images"]["tmp_name"][$key], "../../uploads/pics/" .$_FILES['images']['name'][$key]);


    }
}
echo "<p>Successfully Uploaded Images</p>";

Please i need a reply asap thanks.

  • 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-03T23:32:01+00:00Added an answer on June 3, 2026 at 11:32 pm

    (sorry i have not big time to explain but hope help)

    in your ajax php file

    $errors = array();  // initialize empty error array
    if (sizeof($errors) == 0) {
           ...
           if ($securimage->check($captcha) == false) {
                $errors['captcha_error'] = 'wrong code';
            }
     }
      if (sizeof($errors) == 0) {
            // no errors, send the form
            $return = array('error' => 0, 'message' => 'OK');
            die(json_encode($return));
        } else {
           $errmsg = '';
            foreach ($errors as $key => $error) {
                // set up error messages to display with each field
                $errmsg .= " - {$error}\n";
            }
            $return = array('error' => 1, 'message' => $errmsg);
            die(json_encode($return));
       }
    

    your js

    url: 'ajax.php',
            type: "POST",
            data: $('#formID').serialize(),
            success: function(msg) {
                try {
                    //                    alert( "Data Saved: " + msg );
                    json = jQuery.parseJSON(msg);
                    //                      alert(json.error)
                    if (json.error == 0) {
                    } catch(e) {
                    alert("Sorry, there was an error parsing the json");
                }
            },
            error: function(msg) {
                alert("Ajax request failed");
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i know this is basic but somehow i have been stuck here for some
Im quite stuck here. I have been trying and googling for the past 2
I am stuck here and hope to get some guidance on this. I'm trying
I am stuck here. actually I am trying to fill a PDF form using
I'm still going through some guides on RoR and I'm stuck here at Deploying
I have been stuck here for a good while and seem to nail the
I totally stuck here. I finished my app and when trying to build with
I'm trying to use Google Maps API and i'm stuck here: I need an
I am trying to write merge sort and stuck here. What is the problem
I'm trying to get AppFabric monitoring to work but I'm stuck here. Events are

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.