Since scriptcase hasnt done any proper fixes I’ll post the fixes that I had to do before I got it working reasonably…
I have a editable grid called grid_filestorage with a field FILENAME of the type Document (File Name) and a field NR of type integer with a sequence (in ORACLE).
As in my other posts the following errors will occurs if you create such a grid:
1: filenames are not allowed to have any character >=chr(128) nor are various other characters allowed (+ for example) or some characters are converted inproperly so that when a file is uplaoded it can not be downlaoded anymore.
When the code gets generated you get various files among which:
grid_filestorage_doc.php,grid_filestorage_nmutf8.php,grid_filestorage_sajax_js.php
These files contain minor and major bugs which apparently are still not fixed…
The one below is needed to fix the ‘can not upload a file with a + character in it’ complaint one might have.
grid_filestorage_nmutf8.php:
....
}
function NM_utf8_urldecode($str)
{
if (is_array($str))
{
return $str;
}
$aRep = array(
'&' => '&',
'<' => '<',
'>' => '>',
'"' => '"',
"'" => ''',
'+' => ',',
'?' => 'Á',
'?' => 'á',
replace that with this:
}
function NM_utf8_urldecode($str)
{
return rawurldecode($str);
}
function NM_utf8_urldecode2($str)
{
if (is_array($str))
{
return $str;
}
$aRep = array(
'&' => '&',
'<' => '<',
'>' => '>',
'"' => '"',
"'" => ''',
'+' => '+',
'?' => 'Á',
in file grid_filestorage_sajax_js.php there is a more serious bug which still remains in the original sajax code as well.
This one is needed to fix the rest of the + in the filename bug:
....
function sajax_do_call(func_name, args) {
var i, x, n;
var uri;
var post_data;
var target_id;
sajax_debug(\"in sajax_do_call()..\" + sajax_request_type + \"/\" + sajax_target_id);
target_id = sajax_target_id;
if (typeof(sajax_request_type) == \"undefined\" || sajax_request_type == \"\")
sajax_request_type = \"GET\";
uri = \"" . sajax_url_encode($sajax_remote_uri) . "\";
// NM
if (-1 != uri.indexOf(\"?\"))
uri = uri.substr(0, uri.indexOf(\"?\"));
// NM
if (sajax_request_type == \"GET\") {
if (uri.indexOf(\"?\") == -1)
uri += \"?rs=\" + escape(func_name);
else
uri += \"&rs=\" + escape(func_name);
uri += \"&rst=\" + escape(sajax_target_id);
uri += \"&rsrnd=\" + new Date().getTime();
for (i = 0; i < args.length-1; i++)
uri += \"&rsargs[]=\" + escape(args[i]);
post_data = null;
}
else if (sajax_request_type == \"POST\") {
post_data = \"rs=\" + escape(func_name);
post_data += \"&rst=\" + escape(sajax_target_id);
post_data += \"&rsrnd=\" + new Date().getTime();
for (i = 0; i < args.length-1; i++)
post_data = post_data + \"&rsargs[]=\" + escape(args[i]);
}
else {
alert(\"Illegal request type: \" + sajax_request_type);
}
....
if (sajax_request_type == \"POST\") {
x.setRequestHeader(\"Method\", \"POST \" + uri + \" HTTP/1.1\");
x.setRequestHeader(\"Content-Type\", \"application/x-www-form-urlencoded\");
}
....
thje improved code is:
....
function sajax_do_call(func_name, args) {
var i, x, n;
var s;
var post_data;
var target_id;
sajax_debug(\"in sajax_do_call()..\" + sajax_request_type + \"/\" + sajax_target_id);
target_id = sajax_target_id;
if (typeof(sajax_request_type) == \"undefined\" || sajax_request_type == \"\")
sajax_request_type = \"GET\";
uri = \"" . sajax_url_encode($sajax_remote_uri) . "\";
// NM
if (-1 != uri.indexOf(\"?\"))
uri = uri.substr(0, uri.indexOf(\"?\"));
// NM
if (sajax_request_type == \"GET\") {
if (uri.indexOf(\"?\") == -1)
uri += \"?rs=\" + escape(func_name);
else
uri += \"&rs=\" + escape(func_name);
uri += \"&rst=\" + escape(sajax_target_id);
uri += \"&rsrnd=\" + new Date().getTime();
for (i = 0; i < args.length-1; i++)
uri += \"&rsargs[]=\" + escape(args[i]);
post_data = null;
}
else if (sajax_request_type == \"POST\") {
post_data = \"rs=\" + escape(func_name);
post_data += \"&rst=\" + escape(sajax_target_id);
post_data += \"&rsrnd=\" + new Date().getTime();
for (i = 0; i < args.length-1; i++){
[/color=RED]s=escape(args[i]);
post_data = post_data + \"&rsargs[]=\" + s.replace(\"+\",\"%2B\");[/color]
}
}
else {
alert(\"Illegal request type: \" + sajax_request_type);
}
....
if (sajax_request_type == \"POST\") {
x.setRequestHeader(\"Method\", \"POST \" + uri + \" HTTP/1.1\");
x.setRequestHeader(\"Content-Type\", \"application/x-www-form-urlencoded; charset=iso-8859-15\"); //choose your characterset here!
}