0

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());
$cc=mysql_insert_id();
        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:

$(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;
    }status.text('Uploading...');
    },

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


            $('<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');
        }
        else 
        {
            $('<span></span>').appendTo('#files').text(response).addClass('error');
        }

Please let me know if anyone can help.

I am new to javascript.

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Taywin
0

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...

Edited by Taywin

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.