|
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?
|