Hello Abu
I have been trying your file upload code, It is uploading successfully after I have set the $col["upload_dir"]="../Docs/Contracts". But now I want to record the filename to the database. So can you suggest for me how I can get the filename of the file uploaded in the 'on_after_insert' function.
Best regards
File uploading is in beta stages, and will be released in upcoming version.
It's not functional now.
Hi,
I am also facing the same problem that I am not able to get the uploaded file name.
please help!
Thanks in advance
Hello,
Please refer demos/editing/file-upload.php sample.
If your upload file field was 'note', you will get uploaded file path in $data['params']['note'] in callback
$e["on_insert"] = array("add_invoice", null, true);
$g->set_events($e);
// callback for add
function add_invoice($data)
{
$upload_file_path = $data["params"]["note"];
}
HI Abu,
I used this for column
$col = array();
$col["title"] = "NOTE"; // caption of column
$col["name"] = "note"; // grid column name, must be exactly same as returned
$col["search"] = true;
$col["editable"] = true;
$col["width"] = "10";
$col["edittype"] = "file"; // render as file
$col["upload_dir"] ="temp/"; // upload here
$col["align"] = "center";
$cols[] = $col;
$e = array();
$e["on_insert"] = array("add_expensereport", null, true);
$g->set_events($e);
function add_expensereport($data)
{
$id = $data["id"];
$amount_spent = $data["params"]["amount_spent"];
$category = $data["params"]["categoryname"];
$upload_file_path = $data["params"]["note"];
$date = $data["params"]["date"];
$expense_reason = $data["params"]["expense_reason"];
$currency = $data["params"]["currency"];
mysql_query("INSERT INTO expense_report (category_id,amount_spent,attachment,date,expense_reason,currency,modified_date)values('$category','$amount_spent','$attachment','$date','$expense_reason','$currency',now())") or die(mysql_error());
}
But note value is empty during insert as below:
INSERT INTO expense_report (category_id,amount_spent,note,date,expense_reason,currency,modified_date)values('1','1000','','2015-03-01','test','INR',now())
thanks,
Navaneethan
sry note not attachment
mysql_query("INSERT INTO expense_report (category_id,amount_spent,note,date,expense_reason,currency,modified_date)values('$category','$amount_spent','$upload_file_path','$date','$expense_reason','$currency',now())") or die(mysql_error());
}
Hello,
Currently it stores file name and the actual file contents can be read by file_get_contents function.
If you are using full version, demos/editing/file-upload.php contains working demo.
If using free / old version, please follow http://phpgrid.org/download -> buy
Hi Abu,
How to Resize The Image Before Uploading in file-upload or any zoom in zoom out option available in fancybox for showing image because we didn't want to scroll down instead of that we reduce file size or zoom in option in that if u have idea for that.
Thanks,
P.Navaneethan
Hello,
You can do such alteration after file upload and inside on_insert / on_update event handler.
Refer: http://www.phpgrid.org/docs/#Grid_Events