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

  • Home
  • SEARCH
  • 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 7025575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:59:33+00:00 2026-05-27T23:59:33+00:00

I am new to JQuery and i would say i know nothing in that.

  • 0

I am new to JQuery and i would say i know nothing in that. I wanted to develop a little image uploader involving AJAX. I got this piece of code from google and i got it working. Now i have to use a random image name while uploading the file. The code i have is uploading with the file name of the image itself. I really don’t know where to look at to change the file naming concept. So i decided to trace down from where it starts. Can you guys help me narrow down the issue ? So i will learn some JQuery as well. Here is the code.

$(function(){
    $('#swfupload-control').swfupload({
        upload_url: "upload-file.php?p_id=<?php echo $prod_id; ?>",
        file_post_name: 'uploadfile',
        file_size_limit : "1024",
        file_types : "*.jpg;*.png;*.gif",
        file_types_description : "Image files",
        file_upload_limit : 5,
        flash_url : "js/swfupload/swfupload.swf",
        button_image_url : 'js/swfupload/wdp_buttons_upload_114x29.png',
        button_width : 114,
        button_height : 29,
        button_placeholder : $('#button')[0],
        debug: false
    })
    .bind('fileQueued', function(event, file){
        //alert(file.name);
        var listitem='<tr class="r1" id="'+file.id+'" >'+
            '<td>&nbsp;</td>'+
            '<td><span class="filename"><em>'+file.name+'</em> ('+Math.round(file.size/1024)+' KB) </span>'+
            '<span class="progressvalue" ></span>'+
            '<div class="progressbar" ><div class="progress" ></div></div>'+
            '<p class="status" >Pending</p></td>'+
            '<td>&nbsp;</td>'+
            '<td><span class="cancel" >&nbsp;</span></td>'+
            '</tr>';
        $('#log').append(listitem);
        $('tr#'+file.id+' .cancel').bind('click', function(){
            var swfu = $.swfupload.getInstance('#swfupload-control');
            swfu.cancelUpload(file.id);
            $('tr#'+file.id).slideUp('fast');
        });
        // start the upload since it's queued
        //alert(this.getAttribute("id"))
        $(this).swfupload('startUpload');
    })
    .bind('fileQueueError', function(event, file, errorCode, message){
        alert('Size of the file '+file.name+' is greater than limit');
    })
    .bind('fileDialogComplete', function(event, numFilesSelected, numFilesQueued){
        $('#queuestatus').text('Files Selected: '+numFilesSelected+' / Queued Files: '+numFilesQueued);
    })
    .bind('uploadStart', function(event, file){
        $('#log tr#'+file.id).find('p.status').text('Uploading...');
        $('#log tr#'+file.id).find('span.progressvalue').text('0%');
        $('#log tr#'+file.id).find('span.cancel').hide();
    })
    .bind('uploadSuccess', function(event, file, serverData){
        var item=$('#log tr#'+file.id);
        var content = '<td><img src="images/ProductImages/'+file.name+'" width="50" height="50"/><td/>'
            +'<td>'+file.name+'</td> <td style="text-align: center;">'
            +'<input type="checkbox" value="'+file.name+'" name="main" onClick="update_chk(this.value);"/></td>'
            +'<td>Delete</td>';
        item.html(content);

    })
    .bind('uploadProgress', function(event, file, bytesLoaded){
        //Show Progress
        var percentage=Math.round((bytesLoaded/file.size)*100);
        $('#log tr#'+file.id).find('div.progress').css('width', percentage+'%');
        $('#log tr#'+file.id).find('span.progressvalue').text(percentage+'%');
    })

    .bind('uploadComplete', function(event, file){
        // upload has completed, try the next one in the queue
        $(this).swfupload('startUpload');
    })

});
function update_chk(value){
    document.getElementById("main_name").value = value;
}
  • 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-27T23:59:34+00:00Added an answer on May 27, 2026 at 11:59 pm

    What is the server side technology you using for fileupload, PHP, Java? On server side you can generate a random string and use it as fileame instead of the default one.

    For example in PHP one would do:

    // Where the file is going to be placed
    $target_path = 'uploaded_files/';
    
    /* Add the original filename to our target path.
    Result is "uploaded_files/filename.extension" */
    $target_path = $target_path . basename(md5($_FILES['file']['name'])); 
    
    if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
        echo "The file ".  basename( $_FILES['file']['name']).
        " has been uploaded";
    } else{
        echo "There was an error uploading the file, please try again!";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to jQuery and would like to know if it is possible to
I am new to using jquery and would like to know how to append
I would first want to say that I am very new to javascript and
I'm new to jQuery and would like to parse an XML document. I'm able
I'm pretty new to jQuery/JS. But I have loop in jQuery where I would
I'm new to jQuery. This would be no problem for me using XPath expressions,
I am new to jQuery. Any help would be appreciated I have two radio
Im very new to all coding including jquery. I though this would have been
When writing a new jQuery plugin is there a straightforward way of checking that
I know that JQuery is a very powerful library and was just wondering if

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.