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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:34:50+00:00 2026-05-27T12:34:50+00:00

I am developing an upload script where you can upload an picture, which is

  • 0

I am developing an upload script where you can upload an picture, which is directly previewed. After choosing the file it passes it to an php script which echos the picture. The jQuery in the first code inserts this into my preview . After the picture I am printing some input fields. In the input fields you can enter text you want to have on the picture, if you click preview it modifies the picture and shows it on the position the other picture was, but the input fields should stay there. My code:

<script type="text/javascript"><!--//--><![CDATA[//><!--

$j(document).ready(function() {      
$j('#photoimg').live('change', function() { 
    $j("#preview").html('');
    $j("#preview").html('<img src="loader.gif" alt="Uploading...."/>');
    $j("#imageform").ajaxForm({
        target: '#preview'
        }

    }).submit();
});

}); 
 //--><!]]></script>

In the body I have this:

<div id='preview'>
</div>

I am echoing this:

echo "<img src='uploads/".$actual_image_name."'  class='preview'><br  />";
echo "</div><div id='preview3'>";
echo "Line 1 <input type='text' id='cardtext1' name='cardtext1' value='1'/>";

So I want to close the preview div in my echo and open another one that I can change the html code in the first div (with the picture) without any change to the input fields. The html code should be like:

 <div id='preview'>
 <img src='uploads/test.jpg'  class='preview'><br  />
 </div>  <====this one is missing
 <div id='preview3'>
 <input type='text' id='cardtext1' name='cardtext1' value='1'/>
 </div>

The problem is, if I check the html code of the site it only shows the begin of the new but the closetag is not echoed. I also tried to put it in an php variable but also not working. Why is this? And how to fix?

  • 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-27T12:34:51+00:00Added an answer on May 27, 2026 at 12:34 pm

    Something looks wrong with your JavaScript code (the jQuery part).. It looks like there is an erroneous closing curly brace } here:

    $j('#photoimg').live('change', function() { 
        $j("#preview").html('');
        $j("#preview").html('<img src="loader.gif" alt="Uploading...."/>');
        $j("#imageform").ajaxForm({
            target: '#preview'
        } // <-- right here
        }).submit();
    });
    

    Looks like it should be:

    $j("#imageform").ajaxForm({
        target: '#preview'
    }).submit();
    

    Anyway, what you’re doing by trying to dynamically close that div and inject a new one could be more tricky than its worth. I’ve never tried to do that but I feel like that would not be cross-browser compatible even if you got it working in, say, Firefox for example.

    Instead of using $preview as your target, why not wrap it in another div container and use that:

    <div id="container">
        <div id="preview"></div>
    </div>
    

    Then, your jQuery would look like this:

    $j('#photoimg').live('change', function() { 
        $j("#container").html('')
            .html('<img src="loader.gif" alt="Uploading...."/>');
        $j("#imageform").ajaxForm({
            target: '#container'
        }).submit();
    });
    

    In which case, the resulting PHP would end up like:

    echo '<div id="preview">',
         "<img src=\"uploads/{$actual_image_name}\" class=\"preview\"><br />",
         '</div><div id="preview3">',
         'Line 1 <input type="text" id="cardtext1" name="cardtext1" value="1"/>';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a simple php upload script, and users can upload only ZIP and
I am developing an web application which can upload/download a file from client to
I'm developing a service in which users can upload images and save them in
I am developing an application which uses file upload. My client uses Symantec End
I want to upload file with have only file path in php. Can anyone
I've been developing a image manipulation script which has a background and user can
I'm developing a file upload with JSF. The application saves three dates about the
I'm developing a solution that allows people to upload a DOCX file as a
I'm developing an application in which users upload pictures to server and then send
I am developing a script in PHP for uploading files to a MySQL database.

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.