SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2011
    Location
    zziapex.com
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    upload pic and insert different values in database using jquey...

    Hello

    I wanna update my database and upload picture in my folder after rename the pic but the problem is when i tried to send simple value get from text fields,radio button and check box its working fine but when i wanna upload pic using this it not working

    code is here

    <input type="text" name="film_title" size="45" id="film_title"/>
    <input type="text" name="film_release_date" id="film_release_date" />
    <input type="radio" name="film_industry_language" value="Urdu" id="Urdu" class="film_industry_language" /><label for="Urdu">Urdu</label>
    <input type="checkbox" name="film_genre[]" value="Action" id="Action" class="film_genre" /><label for="Action">Action</label>
    <input type="checkbox" name="film_genre[]" value="Adventure" id="Adventure" class="film_genre"/><label for="Adventure">Adventure</label>
    <input type="file" size="50" name="film_image" id="film_image"/>

    <input type="submit" value="submit whole film info" name="submit" id="save_button" class="submitm"/><span id="save_status"></span>


    <script language="javaScript" type="text/javascript" src="js/jquery.js"></script>
    <script language="javaScript" type="text/javascript">
    $('#save_button').click(function(){
    var film_title = $('#film_title').val();
    var film_release_date = $('#film_release_date').val();
    var film_industry_language = $('.film_industry_language').val();
    var film_image = $('#film_image').val();
    var film_genre="";
    film_genre += $('#Action').val() + "\n";
    film_genre += $('#Adventure').val() + "\n";
    film_genre += $('#Animation').val() + "\n";
    film_genre += $('#Biography').val() + "\n";

    $('#save_status').text('Loading...');

    $.post('ajax/add-new-film-form-ajax.php',{ film_title: film_title , film_release_date:film_release_date , film_industry_language:film_industry_language, film_genre:film_genre, film_image:film_image }, function(data){
    $('#save_status').text(data);


    });
    });
    </script>


    i don't wanna us <form> because when i use this <form> refresh my page can anyone help me to get image_name, image_tmp name..

    Thanks

  2. #2
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,095
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    Hi,

    You can't upload images with ajax because the multipart submissions required for file uploads aren't supported by XMLHttpRequest.
    I've had some success using this plugin to dynamically create a hidden iframe and submit with that, it's not that straightforward but it does work.
    http://cmlenz.github.com/jquery-iframe-transport/

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2011
    Location
    zziapex.com
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for helping me..now its working fine but now i have one more small problem

    I wanna redirect my use to his/her post she/he just make but when i use iframe he show my threat down my form page...
    help me in this how can i redirect use to require page on same tab

    Regards


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •