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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:38:26+00:00 2026-05-25T23:38:26+00:00

After looking around for weeks and being totally confounded by the tutorials that were

  • 0

After looking around for weeks and being totally confounded by the tutorials that were already on the books, I have decided to write my own jQuery upload script. I thought I could get it to work but I am having issues. I will enumerate them:

On the page that I am writing this for, I have placed a jQuery script that looks a little like this:

$(document).ready(function() {
  var thumb = $('#thumb');  

  $('#profilepicinput').live('change', function(){
    $("#preview").html('');
    $("#preview").html('<img src="loader.gif" alt="Uploading...."/>');
    $("#registerpt3").ajaxForm({
      target: $('#registerpt3').attr('action')
    }).submit();
  });

  $('#profilepicbutton').change(function(){
    alert("Boy I hate PHP");
    $.ajax({
      type: "POST",
      url: "register3.php",
      success: function(msg) {
        alert( "Data Saved: " + msg );
        $.ajax({
          type: "POST",
          url: "retrievePic.php",
          success: function(msg) {
            var image = new Image();
            $(image).load(function(){
              console.log("we have uploaded this image");
            }).attr('src', 'images/');
            alert("AJAX Success!");
          },
          error: function(msg) {
            alert(" didn't work");
          }
        });
      },
      error:function(msq){
        alert("didn't work!: " + msg);
      }
    });
  });
});

This calls the following script which will load a picture into a database:

<?php 

session_start();

$email = '';

if (isset($_SESSION['user_email'])) {
  $email = $_SESSION['user_email'];
} else {
  $email = 'dww2@pitt.edu';
}

$link = mysql_connect('censcoredFool.com', 'greetmeet', 'Maverick$41'); 

mysql_select_db(first_1) or die("Opps, You are pretty Got-Damned Stupid!  Did you         realize that?!?!?");

$target = './Uploads/'; 
$target = $target . basename( $_FILES['uploaded']['name']); 

$ok = 1; 

$path = "uploads/";
$Email = $_SESSION['user_email'];
$valid_formats = array("jpg", "png", "gif", "bmp","jpeg");

if (isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST") {
  $name = $_FILES['photoimg']['name'];
  $size = $_FILES['photoimg']['size'];

  if (strlen($name)) {
    list($txt, $ext) = explode(".", $name);
    if (in_array($ext,$valid_formats)) {
      if ($size<(1024*1024)) { // Image size max 1 MB
        $actual_image_name = time().$session_id.".".$ext;
        $tmp = $_FILES['photoimg']['tmp_name'];
        if (move_uploaded_file($tmp, $path.$actual_image_name)) {
          mysql_query("insert into personal_photos      (Email, Pics) values('$email', '$tmp')");
          echo "<img   src='uploads/".$actual_image_name."' class='preview'>";
        } else {
          echo "failed";
        }
      } else {
        echo "Image file size max 1 MB";
      }
    } else {
      echo "Invalid file format..";
    }
  } else {
    echo "Please select image..!";
  }

  exit;
}

What I have doesn’t even seem to work. I get the success alert, but the picture doesn’t even upload. I am guessing the PHP script ran the whole way through but didn’t throw an exception or anything. How do I get this thing to work?

UPDATE: After running Firebug My PHP script isn’t getting the Picture
Not sure why that is. Need to figure out how the $_File datastructure works.

  • 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-25T23:38:27+00:00Added an answer on May 25, 2026 at 11:38 pm

    Most browsers won’t send files via ajax for security purposes. To have a pretend-ajax effect on uploads, you might try the excellent jQuery form plugin, which uses an hidden iframe to do the uploading.

    Since this is the only answer so far – and it’s also right – allow me to give you some OT advice:

    • Most of the people using PHP like PHP (more things in Heaven and Earth, Horatio). Most of them will take your “PHP Sucks” thing as a pretty pretentious thing to say, since your problem has more to do with a lack of basic knowledge of Ajax and http implementations than it has to do with the language’s faults. Thus the lack of answers and the unwelcoming comments.

    • Your witty is my distracting: please make the debugging output in the code you post as descriptive as possible – actually, it would be a useful thing to do to simply write descriptive output anyway – it’s easier to find problems that way, trust me.

    • If a form is made of one hundred fields ond only one is relevant, please post the relevant field only.

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

Sidebar

Related Questions

After looking around (for not terribly long I have to admit) I wonder if
I have a query that is dynamically built after looking up a field list
Hey, So after looking around It seems the consensus is that by using publishProgress()
After looking at RescueTime for windows/mac, it seems that there's a version for linux
After looking a while other google, and the web, I decided to post my
Hmm, sounds easy enough but after looking at the ones that come with StringTemplate,
I recently ran into a quite complex problem and after looking around a lot
I would like to create a process in my application. But after looking around
I want to store a serialized object somewhere and after looking around, realize there
I have beeen looking around for a way to add code highlighting to my

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.