I have two pages one called upload-file.php, this page uploads the image into the database and my folder.

My PHP page looks like this.

    if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file))  

        $insert=mysql_query("insert into match_item_image set item_id='".$_SESSION["session_temp"]."', image='".$name."',   adid='$adid'") or die(mysql_error());
        echo "success".$cc; 

My other page consist of a javascript function which displays my images upon upload.
The problem I am having is that I need to change the image name when uploading it into my folder. I was able to change the image name but when I upload the image it displays blank because the JavaScript function Is looking for the original name of the image, when the users uploads the file.

This is part of the function:



    var btnUpload=$('#upload');
    var status=$('#status');
    new AjaxUpload(btnUpload, {
    action: 'upload-file.php',
    name: 'uploadfile',
    onSubmit: function(file, ext)
     if (! (ext && /^(jpg|png|jpeg|gif)$/.test(ext))){ 
     // extension is not allowed 
    status.text('Only JPG, PNG or GIF files are allowed');
    return false;

    onComplete: function(file, response)
        //On completion clear the status
        //Add uploaded file to list
        var bb=response.substr(0,7)
        var idd=response.replace('success',' ');
        var idb =idd.replace(/^\s*|\s*$/g,'');

            $('<span id='+idd+'></span>').appendTo('#files').html('<img src="upload/+file+" alt="" width="290" height="330" class="image1" /><br><a href="javascript:void(0)"    onClick="deleteFile('+idd+');"  class="image1"   > <span   style="font-weight:bold;   font-size:14px; color:red;" >   Delete     </span></a>').addClass('success');

Please let me know if anyone can help.

I am new to javascript.

Err... Wrong forum... Mod, please move this post... Also, go to this forum or this forum and you should find an answer to what you are looking for. I have seen the exactly the same question before...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.