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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:59:29+00:00 2026-05-26T00:59:29+00:00

I am using the Jquery Form plugging to try and upload a picture to

  • 0

I am using the Jquery Form plugging to try and upload a picture to my mysql DBMS. I use the JqueryForm ajaxForm() call to do this. It calls a php file on my server and that script puts the file into the database. I then attempt to get that file out of the database in the same script. I guess the nuts and bolts of how I do it is irrelevant. I really want to know how I would get a picture back from an ajax call using the AjaxForm call from the jqueryForm pluggin. Does anybody have an example of how to do this using that pluggin? I am a little lost…

<script type="text/javascript" src="jquery.form.js"></script>
<script>
    $(document).ready(function () {
        $('#profilepicbutton').live('change', function () {
            $("#preview").html('');
            $("#preview").html('<img src="loader.gif" alt="Uploading...."/>');
            $("#registerpt3").ajaxForm({
                target: '#preview',
                success: function (data) {
                    $("#preview").html('');
                    $("#preview").append("<img src=" + data + "></img>");
                }
            }).submit();
        });
    });
</script>    

Now, On the jquery form pluggin site, there is a page in particular that has instructions for file uploads…
http://jquery.malsup.com/form/#file-upload
The example that they give is a little blank…

<textarea> 
for (var i=0; i < 10; i++) { 
    // do some processing 
} 
</textarea>

Now, what am I supposed to do with that? Why am I looping through some data structure? If you look on there page, you will see they are remarkable brief in their instructions of what to do. Anybody have any tutorials or advice? Thanks.

UPDATE PHP Code

if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST")
{   
$name = $_FILES['profilepicinput']['name'];
$size = $_FILES['profilepicinput']['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['profilepicinput']['tmp_name'];
            $fp      = fopen($tmp, 'r');
            $data = fread($fp, filesize($tmp));
            $data = addslashes($data);
            fclose($fp);
             values('$email', '$tmp')");

            if(mysql_query("insert into Personal_Photos (Email, Pics) values('$email', '$data')"))
            {
                $query="select Pics, MAX(ID) from Personal_Photos where Email='$email'";
                $result=mysql_query($query) or die("Error: ".mysql_error());
                $row=mysql_fetch_array($result);
                $mime = 'image/yourtype';
                $base64 = base64_encode($contents);
                $uri = "data:$mime;base64,$base64";
                header("Content-type: image/jpg");
                print($row['Pics']);
            }
            else
            {
                die('Invalid query: ' . mysql_error());
                echo "failed";
            }
        }
        else
            echo "Image file size max 1 MB. Image Size:"+$size;
    }
    else
        echo "Invalid file format..";
}
else
    echo "Please select image..! Bull shit".$email;
exit;

}

  • 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-26T00:59:29+00:00Added an answer on May 26, 2026 at 12:59 am

    If I understand your question right, you can create a so called data URI.

    In PHP it’s quite simple:

    $mime = 'image/yourtype';
    $base64 = base64_encode($contents);
    $uri = "data:$mime;base64,$base64";
    

    And pass this as string in the ajax reponse to be directly entered as you outlined in your question.

    Hopefully this helps, I’m not fluent with jqueryform.

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

Sidebar

Related Questions

I have file upload using jquery form plugin as $(function() { $(#Form).ajaxForm({ iframe: true,
I send asynchronous call using jQuery form plugin and in the case of success
I'm using the jQuery Form plugin to upload an image. I've assigned a fade
i am using jquery form plugin for file upload . i am not able
I am using jQuery Form upload. I am unable to upload file with the
I am using jQuery.Form to upload files on server. Here is an sample I
I am using jquery form plugin for file upload . my question is how
I'm using jQuery's form plugin (as suggested in a number of threads like this
I'm using this jQuery form validator but I cannot understand how to make one
I am using jQuery form plugin to upload images in my MVC project. For

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.