Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
athlete pic
-
- Posts: 5
- Joined: Tue Mar 04, 2014 7:31 pm
athlete pic
Hi there,
I am trying to bring the gym db on the web and I discovered nuBuilder.
I am finding it very simple and easy. Wonderful!
I just don't find how to have the picture of the athlete in the form, either taking the data from a blob column in my personal details table or taking its path in the images subdirectory from a text filed in the same table or using the Home-Images facility.
It can see a picture by entering a code like <img src = "images/filename.jpg"> on Home-Objects-HTML but in this way it has no link to the db.
I read all the wiki pages that cold be directly related to images and I saw all the videos.
I have very little knowledge of PHP programming.
Could you please help me?
Thanks in advance
Kind regards,
Dan
I am trying to bring the gym db on the web and I discovered nuBuilder.
I am finding it very simple and easy. Wonderful!
I just don't find how to have the picture of the athlete in the form, either taking the data from a blob column in my personal details table or taking its path in the images subdirectory from a text filed in the same table or using the Home-Images facility.
It can see a picture by entering a code like <img src = "images/filename.jpg"> on Home-Objects-HTML but in this way it has no link to the db.
I read all the wiki pages that cold be directly related to images and I saw all the videos.
I have very little knowledge of PHP programming.
Could you please help me?
Thanks in advance
Kind regards,
Dan
-
- Posts: 5
- Joined: Tue Mar 04, 2014 7:31 pm
Re: athlete pic
Hi there,
with this page:
http://forums.nubuilder.cloud/viewtopic.p ... age#p11256
I resolved the visulisation issue with an extra simple <img src="#Picture#">.
Now, the problem is how to place a button to enter/change the picture path and/or upload the file from client to a directory on the server (possibly, in a preferred "images" dir)
Thanks in advance
Best regards,
Daniele
with this page:
http://forums.nubuilder.cloud/viewtopic.p ... age#p11256
I resolved the visulisation issue with an extra simple <img src="#Picture#">.
Now, the problem is how to place a button to enter/change the picture path and/or upload the file from client to a directory on the server (possibly, in a preferred "images" dir)
Thanks in advance
Best regards,
Daniele
Re: athlete pic
Daniele,
In the latest update is a Javascript function called nuFile(), its explained here https://www.nubuilder.net/documentation ... 77fe52e48b
or you can just hard code it
(pp being the nuBuilderPro code)
Hope this helps
Steven
In the latest update is a Javascript function called nuFile(), its explained here https://www.nubuilder.net/documentation ... 77fe52e48b
or you can just hard code it
Code: Select all
eg. <img id="theimage" src="nufileget.php?pp" align="middle" height="250" width="350">
Hope this helps
Steven
-
- Posts: 5
- Joined: Tue Mar 04, 2014 7:31 pm
Re: athlete pic
Hi there Steven,
thanks a lot for your answer.
Please correct me if I am wrong: you are suggesting me to use such functions [nufile() and nufileget.php] which rely on nuBuilderPro zzzsys_file table that stores the file within the db as a blob.
Please bear with me if would like to keep the gym db light by putting these files on a 'images' dir on the server and not as blobs on the db.
Beyond that, I could not imagine how to relate each record in the athlete table with the corresponding record in the zzzsys_file table.
To circumvent this problem, I put two objects in the form, the first being <img src="#Foto#"> HTML field, the second, an iframe pointing to a "carica" PHP code:
I therefore created a "carica.php"" file:
Till this point something works: clicking on the "Choose file" button I can pick the file and, with "Carica" button, the file is transferred to the "images" directory as expected.
The problem is now how to write path and file name in the athlete table.
I am trying several versions of Forms-Custom Code-After Save like this:
or
or
But it does work yet.
The issue is how to pass the return value of the "carica.php" code to the form.
Here https://www.nubuilder.net/documentation ... 2b5841457b , I found that:
"To store the file contents and information into the database we use the After Save tab on the Custom Code section of the form. On a successful upload to the server a JSON string is saved into a Hash Variable #FILES# so we can fetch the file information from this using the json_decode function from PHP."
but it seems that the referred JSON #FILES# is created by nuupload.php
thanks a lot for your answer.
Please correct me if I am wrong: you are suggesting me to use such functions [nufile() and nufileget.php] which rely on nuBuilderPro zzzsys_file table that stores the file within the db as a blob.
Please bear with me if would like to keep the gym db light by putting these files on a 'images' dir on the server and not as blobs on the db.
Beyond that, I could not imagine how to relate each record in the athlete table with the corresponding record in the zzzsys_file table.
To circumvent this problem, I put two objects in the form, the first being <img src="#Foto#"> HTML field, the second, an iframe pointing to a "carica" PHP code:
Code: Select all
$h = "
<html>
<body style='background-color:lightgrey'>
<form enctype='multipart/form-data' action='carica.php' method='POST'>
<input name='Foto' type='file' />
<input type='submit' value='Carica' />
</form>
</body>
</html>
";
print $h;
Code: Select all
<?php
require_once('nucommon.php');
$allowedExts = array("gif", "jpeg", "jpg", "bmp", "png");
$temp = explode(".", $_FILES["Foto"]["name"]);
$extension = end($temp);
if ((($_FILES["Foto"]["type"] == "image/gif")
|| ($_FILES["Foto"]["type"] == "image/jpeg")
|| ($_FILES["Foto"]["type"] == "image/jpg")
|| ($_FILES["Foto"]["type"] == "image/pjpeg")
|| ($_FILES["Foto"]["type"] == "image/bmp")
|| ($_FILES["Foto"]["type"] == "image/x-png")
|| ($_FILES["Foto"]["type"] == "image/png"))
&& in_array($extension, $allowedExts))
{
if ($_FILES["Foto"]["error"] > 0)
{
echo "Return Code: " . $_FILES["Foto"]["error"] . "<br>";
}
else
{
echo "Carica: " . $_FILES["Foto"]["name"] . "<br>";
echo "Tipo: " . $_FILES["Foto"]["type"] . "<br>";
echo "Dimensione: " . ($_FILES["Foto"]["size"]) . "<br>";
echo "Temporaneo: " . $_FILES["Foto"]["tmp_name"] . "<br>";
if (file_exists("images/" . $_FILES["Foto"]["name"]))
{
echo $_FILES["Foto"]["name"] . " gia esiste. ";
}
else
{
$Foto = "images/" . $_FILES["Foto"]["name"];
move_uploaded_file($_FILES["Foto"]["tmp_name"], $Foto);
echo "Caricato su: ". $Foto . "\n";
// $s = "UPDATE atleta SET Foto = '" . $Foto . "' WHERE ID = '#RECORD_ID#'"; it does not work
// print $s;
// nuRunQuery($s);
return $Foto;
}
}
}
else
{
echo "File errato";
}
?>
The problem is now how to write path and file name in the athlete table.
I am trying several versions of Forms-Custom Code-After Save like this:
Code: Select all
$s = "UPDATE atleta SET Foto = $Foto WHERE ID = '#RECORD_ID#'";
nuRunQuery($s);
Code: Select all
$s = "UPDATE atleta SET Foto = '$Foto' WHERE ID = '#RECORD_ID#'";
nuRunQuery($s);
Code: Select all
$s = "UPDATE atleta SET Foto = '#Foto#' WHERE ID = '#RECORD_ID#'";
nuRunQuery($s);
The issue is how to pass the return value of the "carica.php" code to the form.
Here https://www.nubuilder.net/documentation ... 2b5841457b , I found that:
"To store the file contents and information into the database we use the After Save tab on the Custom Code section of the form. On a successful upload to the server a JSON string is saved into a Hash Variable #FILES# so we can fetch the file information from this using the json_decode function from PHP."
but it seems that the referred JSON #FILES# is created by nuupload.php
Re: athlete pic
Daniele,
To be honest, there are far better ways to manage pictures, like putting them in dropbox and linking to them there.
Steven
To be honest, there are far better ways to manage pictures, like putting them in dropbox and linking to them there.
Steven
-
- Posts: 5
- Joined: Tue Mar 04, 2014 7:31 pm
Re: athlete pic
Steven,
for dropbox, do you mean the nuBuilderPro facility, as shown in the link below?
https://www.nubuilder.net/documentation ... 2b5841457b
Daniele
for dropbox, do you mean the nuBuilderPro facility, as shown in the link below?
https://www.nubuilder.net/documentation ... 2b5841457b
Daniele
-
- Posts: 5
- Joined: Tue Mar 04, 2014 7:31 pm
Re: athlete pic
I found it!
I passed the record id as an idden value from the iframed PHP Code to the carica.php executing the update, without using After Save.
Here the iframed PHP Code:
Here the carica.php:
I passed the record id as an idden value from the iframed PHP Code to the carica.php executing the update, without using After Save.
Here the iframed PHP Code:
Code: Select all
$h = "
<html>
<body style='background-color:lightgrey'>
<form enctype='multipart/form-data' action='carica.php' method='POST'>
<input name='Foto' type='file' />
<input type='hidden' name='Record' value='#RECORD_ID#'>
<input type='submit' value='Carica' />
</form>
</body>
</html>
";
print $h;
Code: Select all
<?php
require_once('nucommon.php');
$allowedExts = array("gif", "jpeg", "jpg", "bmp", "png");
$temp = explode(".", $_FILES["Foto"]["name"]);
$extension = end($temp);
if ((($_FILES["Foto"]["type"] == "image/gif")
|| ($_FILES["Foto"]["type"] == "image/jpeg")
|| ($_FILES["Foto"]["type"] == "image/jpg")
|| ($_FILES["Foto"]["type"] == "image/pjpeg")
|| ($_FILES["Foto"]["type"] == "image/bmp")
|| ($_FILES["Foto"]["type"] == "image/x-png")
|| ($_FILES["Foto"]["type"] == "image/png"))
&& in_array($extension, $allowedExts))
{
if ($_FILES["Foto"]["error"] > 0)
{
echo "Return Code: " . $_FILES["Foto"]["error"] . "<br>";
}
else
{
echo "Carica: " . $_FILES["Foto"]["name"] . "<br>";
echo "Tipo: " . $_FILES["Foto"]["type"] . "<br>";
echo "Dimensione: " . ($_FILES["Foto"]["size"]) . "<br>";
echo "Temporaneo: " . $_FILES["Foto"]["tmp_name"] . "<br>";
if (file_exists("images/" . $_FILES["Foto"]["name"]))
{
echo $_FILES["Foto"]["name"] . " gia esiste. ";
}
else
{
$Foto = "images/" . $_FILES["Foto"]["name"];
move_uploaded_file($_FILES["Foto"]["tmp_name"], $Foto);
echo "Caricato su: ". $Foto . "\n";
$s = "UPDATE atleta SET Foto = '" . $Foto . "' WHERE ID = " . $_POST['Record'];
print $s;
nuRunQuery($s);
}
}
}
else
{
echo "File errato";
}
?>