Jump to content

pull info for posting from javascript code area


searls03

Recommended Posts

I don't believe this is js help, so I put it here.....how do I pull the form field "id" and post to the database from this code?

 

$(function(){  
    $('#swfupload-control').swfupload({  
        upload_url: "upload-file.php",  
        file_post_name: 'uploadfile',  
        file_size_limit : "9999999999999999999999999999999999",  
        file_types : "*",  
        file_types_description : "Image files",  
        file_upload_limit : 1000,  
        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){  
            var listitem='<li id="'+file.id+'" >'+  
                'File: <em>'+file.name+'</em> ('+Math.round(file.size/1024)+' KB) <span class="progressvalue" ></span>'+  
                '<div class="progressbar" ><div class="progress" >
////////////////////////right here
<input type="hidden" name="id" value="<?php echo $str; ?>" /></div></div>'+  
                '<p class="status" >Pending</p>'+  
                '<span class="cancel" > </span>'+

 

here is the code that posts:

<?php
include_once "secure/connect_to_mysql.php";

$uploaddir = 'images/';
$id= $_POST['id'];
$file = $uploaddir . basename($_FILES['uploadfile']['name']); 
$size=$_FILES['uploadfile']['size'];
if($size>999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999)
{
echo "error file size > 1 MB";
unlink($_FILES['uploadfile']['tmp_name']);
exit;
}
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) { 
  echo "success"; 
} else {
echo "error ".$_FILES['uploadfile']['error']." --- ".$_FILES['uploadfile']['tmp_name']." %%% ".$file."($size)";
}
$sql = "INSERT INTO pictures(image, id) 
	VALUES('$file', '$id')";
$rs = mysql_query($sql) or die ("Problem with the query: $sql<br>" . mysql_error());
	echo mysql_error();


?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.