This topic is locked
[SOLVED]

 Image/file issue

12/21/2019 7:29:00 AM
PHPRunner General questions
M
mhollibush author


global $pageObject;

$data = $pageObject->getCurrentRecord();

$sql = "SELECT

*

FROM pictures where dogid =".$data["id"]." ";

$rspictures = CustomQuery($sql);
echo "<table width='100%' border='1' bordercolor='#C0C0C0' cellpadding='5' >";

echo "<tr>";

while($data1=db_fetch_array($rspictures))
{

echo "<tr><td style='padding: 5px 10px 5px 5px;'>&nbsp;&nbsp;". $data1["picture"]."</td>";

echo "<td style='padding: 5px 10px 5px 5px;'>&nbsp;&nbsp;". $data1["pic_note"]."</td>";

echo "</tr>";
}

echo "</table>";


How do you get the clickable thumbnail to display and popup the picture when clicked?


( temp images location )

HJB 12/21/2019

https://xlinesoft.com/phprunner/docs/edit_as_settings_file_image.htm
.. indeed, from the seen screenshot, it's evident, the THUMBNAILS had either

been not created or are not correctly linked. To get it to work, run through

the URL content above to better understand and to solve the issue.

M
mhollibush author 12/21/2019



https://xlinesoft.com/phprunner/docs/edit_as_settings_file_image.htm
.. indeed, from the seen screenshot, it's evident, the THUMBNAILS had either

been not created or are not correctly linked. To get it to work, run through

the URL content above to better understand and to solve the issue.


I think the issue that is that the pictures are stored as:

when uploading an image - it creates the thumbnail and image and stores them as shown



[{"name":"files\/our_pictures\/DSC05547_r38vwyoh.JPG","usrName":"DSC05547.JPG","size":3075970,"type":"image\/jpeg","thumbnail":"files\/our_pictures\/thDSC05547_w4yp326r.JPG","thumbnail_type":"image\/jpeg","thumbnail_size":11808,"searchStr":"DSC05547.JPG,!:sStrEnd"}]


I need to somehow get the images out of the string

HJB 12/21/2019



I think the issue that is that the pictures are stored as:

when uploading an image - it creates the thumbnail and image and stores them as shown



[{"name":"files\/our_pictures\/DSC05547_r38vwyoh.JPG","usrName":"DSC05547.JPG","size":3075970,"type":"image\/jpeg","thumbnail":"files\/our_pictures\/thDSC05547_w4yp326r.JPG","thumbnail_type":"image\/jpeg","thumbnail_size":11808,"searchStr":"DSC05547.JPG,!:sStrEnd"}]


I need to somehow get the images out of the string


It was very very long time ago when I delt last with THUMBNAILS issues, yet even for me, in the beginning, it was difficult to understand the logics. First, pictures can be stored either as FILE or IMAGE (in a BLOB). So can the THUMBNAILS. I guess you use storage as FILE, so the strings are appearing. You would need to experiment a little bit with picture storage under IMAGE (and BLOB as field formatting) to somehow solve the "strings" Problem.

A
acpan 12/22/2019

Try this tip Image Upload
It will give you some understanding how to deal with the image and thumbnail.
ACP

M
mhollibush author 12/22/2019



Try this tip Image Upload
It will give you some understanding how to deal with the image and thumbnail.
ACP


thanks for the tip
I still don't understand how to get the image and thumbnail out of the stored string.
QUESTION:

is there a way to store just the image name and thumbnail name in separate columns in the table?

Example:

Have the picture column store the full binary string

then

also store the just the image name in a second column and the thumbnail name in a third column?
Would be even better if I could use the built in viewer instead of linking to the individual images and thumbnails <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=89688&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />

A
acpan 12/22/2019

On your question:
>>I still don't understand how to get the image and thumbnail out of the stored string.
It is there in the tip, step by step with explanation how to extract the file names, isn't it what you want? Here's the extract from tip:


// Example of json data string stored in Database:

/*

[{"name":"images/logo_lesqftiw.png","usrName":"logo.png","size":29968,"type":"image/png",

"thumbnail":"images/thlogo_b4z7g738.png","thumbnail_type":"image/png","thumbnail_size":29968,

"searchStr":"logo.png,!:sStrEnd"}]
*/
// Our database table column to store json string is: defaultLogo

// Our sub-folder in the generated project is: images (we set this in PHPRunner, default folder in

// PHPRunner IS NOT images).
// After add event, $values["defaultLogo"] is the field that store the image json string.

// So, json decode $values["defaultLogo"] into array to extract the image names:
$fileArray = json_decode($values["defaultLogo"],true);



// Since we allow 1 image upload in PHPrunner, first array, $fileArray[0] will store that image json string.

// if multiple images upload allowed, $fileArray will contains $fileArray[0], $fileArray[1] ... etc.

// To decode multiple images from json string, read this manual: https://xlinesoft.com/phprunner/docs/rename_uploaded_file.htm
$image_name_with_path = $fileArray[0]['name'];

$image_name_only = $fileArray[0]['usrName'];

$thumbnail_with_path = $fileArray[0]['thumbnail'];
// the physical image files are located in your_phprunner_project_folder/images/your_images.png.

// the folder "images" are set in the PHPRunner image field setting, if you choose default, it will

// likely be a sub-folder called "file".



// you can copy the above to another fields in the after add event, if you like, eg:

$values["my_seperate_image_file"] = $image_name_only;

$values["my_seperate_thumbnail_file_with_path"] = $thumbnail_with_path;



>>QUESTION:

>>is there a way to store just the image name and thumbnail name in separate columns in the table?
Extract the names from json first, than you can store in two columns in the after add events, but if you can extract from json, you don't need to store in 2 columns.
>>Example:

>>Have the picture column store the full binary string then

>>also store the just the image name in a second column and the thumbnail name in a third column?
Storing as binary file in DB is a separate method from storing as physical files (choose one method). Storing in DB has some limitation, such as it does not support multiple images and the picture gallery.
Also, you can try the official demo 2, under products, there is image upload function, and you can also download the project file to try out too.
ACP

M
mhollibush author 12/23/2019



On your question:
>>I still don't understand how to get the image and thumbnail out of the stored string.
It is there in the tip, step by step with explanation how to extract the file names, isn't it what you want? Here's the extract from tip:


// Example of json data string stored in Database:

/*

[{"name":"images/logo_lesqftiw.png","usrName":"logo.png","size":29968,"type":"image/png",

"thumbnail":"images/thlogo_b4z7g738.png","thumbnail_type":"image/png","thumbnail_size":29968,

"searchStr":"logo.png,!:sStrEnd"}]
*/
// Our database table column to store json string is: defaultLogo

// Our sub-folder in the generated project is: images (we set this in PHPRunner, default folder in

// PHPRunner IS NOT images).
// After add event, $values["defaultLogo"] is the field that store the image json string.

// So, json decode $values["defaultLogo"] into array to extract the image names:
$fileArray = json_decode($values["defaultLogo"],true);
// Since we allow 1 image upload in PHPrunner, first array, $fileArray[0] will store that image json string.

// if multiple images upload allowed, $fileArray will contains $fileArray[0], $fileArray[1] ... etc.

// To decode multiple images from json string, read this manual: https://xlinesoft.com/phprunner/docs/rename_uploaded_file.htm
$image_name_with_path = $fileArray[0]['name'];

$image_name_only = $fileArray[0]['usrName'];

$thumbnail_with_path = $fileArray[0]['thumbnail'];
// the physical image files are located in your_phprunner_project_folder/images/your_images.png.

// the folder "images" are set in the PHPRunner image field setting, if you choose default, it will

// likely be a sub-folder called "file".
// you can copy the above to another fields in the after add event, if you like, eg:

$values["my_seperate_image_file"] = $image_name_only;

$values["my_seperate_thumbnail_file_with_path"] = $thumbnail_with_path;


>>QUESTION:

>>is there a way to store just the image name and thumbnail name in separate columns in the table?
Extract the names from json first, than you can store in two columns in the after add events, but if you can extract from json, you don't need to store in 2 columns.
>>Example:

>>Have the picture column store the full binary string then

>>also store the just the image name in a second column and the thumbnail name in a third column?
Storing as binary file in DB is a separate method from storing as physical files (choose one method). Storing in DB has some limitation, such as it does not support multiple images and the picture gallery.
Also, you can try the official demo 2, under products, there is image upload function, and you can also download the project file to try out too.
ACP


I will give this a try when I get home today....

That makes more sense to me now...

This is a so-called hobby project for our show kennel and I am tweaking it as I learn new things.

I appreciate your dedication to my question and will reply with the results once I try this.
Because I am doing a INNER JOIN on the view page, Where would I use the json_decode to get the image and thumbnail to display on the view page?