Well... I've figured out how to reference a button by name. The syntax is as follows:
Code: Select all
$("button[name=send_csv]").click(function() {
var pass_file = document.addressbk_frm.file.value;
$('#demo').html(pass_file);
$.post("addressbk_data_1.php",{bind_file:pass_file},function(data){
$('#demo').html(data);
});
});
But now there is another problem.
var pass_file = document.addressbk_frm.file.value; references
<input type="file" style="height:20px" name="file"/>.
Currently - the uploaded file is being processed by submit to the same page. I am trying to move the processing of this file to a separate .php file, and am using the
.click(function) to trigger the processing.
The following
$.post is used to pass the user uploaded file to the processing .php page.
Code: Select all
$.post("addressbk_data_1.php",{bind_file:pass_file},function(data){
$('#demo').html(data);
});
However, the processing php file is not treating
$.post("addressbk_data_1.php",{bind_file:pass_file},function(data) as a file.
My .php processing file is as follows:
Code: Select all
<?php
session_start();
// include database connection file, if connection doesn't work the include file will throw an error message
include '../tfm/include/db_connect.php';
// include data process file - contains custom functions.
include '../tfm/include/custom_functions.php';
// Define user_id and record date for INSERT and UPDATE Statements
$userid = $_SESSION['user_id'];
$firstcontact = date("Y-m-d");
/////////-------------testing here
$file = $_POST['bind_file'];
$_FILES["file"]["tmp_name"] = $_POST['bind_file'];
if (file_exists($file));
{
echo "files variable: " . $_FILES['file']['tmp_name'] . "<br />";
echo "file type: " . $_FILES['file']['type'] . "<br />";
}
///////////----------------End testing
?>
This echo line returns a value:
Code: Select all
echo "files variable: " . $_FILES['file']['tmp_name'] . "<br />";
This echo line does not return a value:
Code: Select all
echo "file type: " . $_FILES['file']['type'] . "<br />";
__________________________________________________
Since the file is currently being processed through a submit to the same page, the $_FILES variable just picks up the file from the $_POST. But it seems passing user input through a jQuery $.post changes the input and my processing page does not recognize it as a
file. How do I remedy this?
Thanks so much - Pavilion