Welcome to the nuBuilder forums!
Please register and login to view forums and other content only available to registered users.
Please register and login to view forums and other content only available to registered users.
Show Pictures
-
- Posts: 41
- Joined: Mon Jan 18, 2016 3:01 pm
Show Pictures
Hi!
My hope was to use this example: http://wiki.nubuilder.net/nubuilderv3/i ... base_table
As it did not work out. I downloaded the Sample Application provided here: https://www.nubuilder.net/sample.php
It should look like this: It looked like this: What am I doing wrong? Is the Sample Application outdated?
Testing it on my live application gives better results. I get the upload dialog. But by saving the data, I get a "Requested JSON parse failed.": I hope somebody can help!
Thx,
Timo
My hope was to use this example: http://wiki.nubuilder.net/nubuilderv3/i ... base_table
As it did not work out. I downloaded the Sample Application provided here: https://www.nubuilder.net/sample.php
It should look like this: It looked like this: What am I doing wrong? Is the Sample Application outdated?
Testing it on my live application gives better results. I get the upload dialog. But by saving the data, I get a "Requested JSON parse failed.": I hope somebody can help!
Thx,
Timo
-
- Posts: 41
- Joined: Mon Jan 18, 2016 3:01 pm
Re: Show Pictures
The fields have been created in my table. The Custom Code in the After Save section has been customized accordingly:
____________________________________________________________________________________
IF("#FILES#" != '#FILES'.'#'){ //has something been uploaded?
$J = json_decode("#FILES#"); //fetch the uploaded file information
$name = $J[0]->{'name'};
$type = $J[0]->{'type'};
$contents = file_get_contents(sys_get_temp_dir().$name); //obtain the contents of the file
$contents = addslashes($contents);
//put the file information and contents into the database
$s = "
UPDATE inventory
SET
inventory_file_blob = '$contents',
inventory_file_name = '$name',
inventory_file_type = '$type'
WHERE INVENTRORY_ID = '#RECORD_ID#'
";
nuRunQuery($s);
unlink(sys_get_temp_dir().$name); //delete the temporary file.
}
____________________________________________________________________________________
Also the PHP Code: SHOW I found in the Sample Application has been modified accordingly:
____________________________________________________________________________________
$s = "
SELECT *
FROM inventory
WHERE INVENTRORY_ID = '#RECORD_ID#'
";
$t = nuRunQuery($s);
$r = db_fetch_object($t);
header("Content-Type: $r->inventory_file_type");
echo $r->inventory_file_blob;
____________________________________________________________________________________
It seems that I have two issues:
Thank you so much, it is a great application to me,
Timo
____________________________________________________________________________________
IF("#FILES#" != '#FILES'.'#'){ //has something been uploaded?
$J = json_decode("#FILES#"); //fetch the uploaded file information
$name = $J[0]->{'name'};
$type = $J[0]->{'type'};
$contents = file_get_contents(sys_get_temp_dir().$name); //obtain the contents of the file
$contents = addslashes($contents);
//put the file information and contents into the database
$s = "
UPDATE inventory
SET
inventory_file_blob = '$contents',
inventory_file_name = '$name',
inventory_file_type = '$type'
WHERE INVENTRORY_ID = '#RECORD_ID#'
";
nuRunQuery($s);
unlink(sys_get_temp_dir().$name); //delete the temporary file.
}
____________________________________________________________________________________
Also the PHP Code: SHOW I found in the Sample Application has been modified accordingly:
____________________________________________________________________________________
$s = "
SELECT *
FROM inventory
WHERE INVENTRORY_ID = '#RECORD_ID#'
";
$t = nuRunQuery($s);
$r = db_fetch_object($t);
header("Content-Type: $r->inventory_file_type");
echo $r->inventory_file_blob;
____________________________________________________________________________________
It seems that I have two issues:
- Hitting the Save-Button gives me the message "Requested JSON parse failed." The table fields inventory_file_name and inventory_file_type get filled, but inventory_file_blob stays emty.
- After manually uploading the BLOB via phpMyAdmin it looks like in the Sample Application on my XAMPP
Thank you so much, it is a great application to me,
Timo
-
- Posts: 41
- Joined: Mon Jan 18, 2016 3:01 pm
Re: Show Pictures
Hi!
It looks like a general problem. I tried to descibe it as detailed as possible, in hope to get some feedback.
I cheked:
It looks like a general problem. I tried to descibe it as detailed as possible, in hope to get some feedback.
I cheked:
- write permition on tmp => okay
- PHP Version => 5.6.15
- post_max_size in php.ini => 8M
- Why does nuBuilder fill the fields inventory_file_name and inventory_file_type, but leaves the field inventory_file_blob empty? (please see above for detailed description)
-
- Posts: 41
- Joined: Mon Jan 18, 2016 3:01 pm
Re: Show Pictures
Dear Steven,
thank you very much for your support. I am very grateful! I uploaded the new livedemo right away to my XAMPP.
The errors remain the same as shown in the second picture of my first post:
The iFrame "uloadpic" shows: "Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\nubuilder\nucommon.php on line 1101"
The iFrame "showpic" shows: "Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\nubuilder\nucommon.php on line 1101"
I checked the Custom Code in the After Save section of the form and the PHP Code of FILE and SHOW. They seems to be identical like in the old demo.
I checked the line 1101 in nucommon.php:
It does not give me any hint. I hope you got the clue!
Is there something wrong with my setup?
Thank you,
Timo
thank you very much for your support. I am very grateful! I uploaded the new livedemo right away to my XAMPP.
The errors remain the same as shown in the second picture of my first post:
The iFrame "uloadpic" shows: "Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\nubuilder\nucommon.php on line 1101"
The iFrame "showpic" shows: "Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\nubuilder\nucommon.php on line 1101"
I checked the Custom Code in the After Save section of the form and the PHP Code of FILE and SHOW. They seems to be identical like in the old demo.
I checked the line 1101 in nucommon.php:
Code: Select all
1093 function nuBuildHashData($J, $T){
1094
1095 $hash = array();
1096 $ignore = array();
1097 $ignore[] = 'sre_layout';
1098 $ignore[] = 'form_data';
1099 $ignore[] = 'slp_php';
1100
1101 foreach($J as $key => $v){ //-- add current hash variables
1102
1103 if(!in_array($key, $ignore)){
1104 $hash['' . $key . ''] = $v;
1105 }
1106
1107 }
Is there something wrong with my setup?
Thank you,
Timo
-
- Posts: 4
- Joined: Tue Jun 07, 2016 5:00 am
Re: Show Pictures
I am having the same issue. imported demo project to my nuBuilder instance, the same error occurs.
Hope Steven can dig it out.
Hope Steven can dig it out.
-
- Posts: 4
- Joined: Wed Jun 15, 2016 2:08 pm
Re: Show Pictures
Hello all,
It took me 2 days to find an obvious bug in the upload code. The issue was that the blob in the database was empty. That was because the file_get_contents() function was not given a proper input.
In order to solve this bug just replace in the "after save" section the line:
with
Good luck!
It took me 2 days to find an obvious bug in the upload code. The issue was that the blob in the database was empty. That was because the file_get_contents() function was not given a proper input.
In order to solve this bug just replace in the "after save" section the line:
Code: Select all
$contents = file_get_contents(sys_get_temp_dir().$name);
Code: Select all
$contents = file_get_contents(sys_get_temp_dir().'/'.$name);
-
- Posts: 4
- Joined: Tue Jun 07, 2016 5:00 am
Re: Show Pictures
tried the new code with no luck......marius wrote:Hello all,
It took me 2 days to find an obvious bug in the upload code. The issue was that the blob in the database was empty. That was because the file_get_contents() function was not given a proper input.
In order to solve this bug just replace in the "after save" section the line:
withCode: Select all
$contents = file_get_contents(sys_get_temp_dir().$name);
Good luck!Code: Select all
$contents = file_get_contents(sys_get_temp_dir().'/'.$name);
-
- Posts: 41
- Joined: Mon Jan 18, 2016 3:01 pm
Re: Show Pictures
Great Marius!
The upload into the data base is working for me. Thank you for the new code. What is still not working is the SHOW.php
The iFrames shows the same error message after upload:
The iFrame "uloadpic" shows: "Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\nubuilder\nucommon.php on line 1101"
The iFrame "showpic" shows: "Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\nubuilder\nucommon.php on line 1101"
Thanks for the help! I hope you have an idea for the last issue.
Greetings,
Timo
The upload into the data base is working for me. Thank you for the new code. What is still not working is the SHOW.php
The iFrames shows the same error message after upload:
The iFrame "uloadpic" shows: "Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\nubuilder\nucommon.php on line 1101"
The iFrame "showpic" shows: "Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\nubuilder\nucommon.php on line 1101"
Thanks for the help! I hope you have an idea for the last issue.
Greetings,
Timo
-
- Posts: 4
- Joined: Wed Jun 15, 2016 2:08 pm
Re: Show Pictures
Please check in phpmyadmin if the blob that you uploaded is empty or not. The above modification should fix the update of the blob in the db.ywauto wrote:
tried the new code with no luck......
Before the modification the file path was something like "/tmpmyfile.png". After the modification the new file path is "/tmp/myfile.png".