![]() |
Admin 12/18/2013 |
Your code looks correct however it assumes that file name is file.jpg which is not always the case. |
J
|
jianwong author 12/19/2013 |
Your code looks correct however it assumes that file name is file.jpg which is not always the case. What is the actual content of photo field in the database when it does have uploaded file info?
|
C
|
copper21 12/19/2013 |
I did notice that you are using "$value" in your IF statement. In a "view as" I think you need to use "$data". |
![]() |
Admin 12/19/2013 |
Jian, |
J
|
jianwong author 12/19/2013 |
Jian, I still need my answer. Here is the question: What is the actual content of photo field in the database when it does have uploaded file info?
|
![]() |
Admin 12/20/2013 |
Thanks, this is what I was asking. Your code is almost right assuming that all table and field names are correct (case-sensitive). |
J
|
jianwong author 12/23/2013 |
Thanks, this is what I was asking. Your code is almost right assuming that all table and field names are correct (case-sensitive). The only missing part is the file name. This sample code uses the hardcoded value of "file.jpg" while you need to read it from the database as well. For instance in your case correct file name will be "081008.jpg". What you need to do is to extract this file name from the database field value stored in JSON format. You can find examples of parsing JSON format at http://xlinesoft.com/phprunner/docs/rename_uploaded_file.htm
|
![]() |
Admin 12/23/2013 |
You should not be pasting file renaming code anywhere. This is just an example of how you can parse JSON format and access values of different parameters like "name" or "usrName". |
J
|
jianwong author 12/23/2013 |
You should not be pasting file renaming code anywhere. This is just an example of how you can parse JSON format and access values of different parameters like "name" or "usrName". You need to write the code that extrcts the value of usrName parameter from the JSON stored in the database and use this file name in your 'View as' Custom expression. This isn't something you can copy and paste.
|
![]() |
Admin 12/23/2013 |
It is already in the sample code you posted. $fileName = $fileArray[$i]["name"];
$fileName = $fileArray[$i]["usrName"]; |
J
|
jianwong author 12/23/2013 |
It is already in the sample code you posted. The following line from sample code you posted extracts the value of "name" parameter: $fileName = $fileArray[$i]["name"];
$fileName = $fileArray[$i]["usrName"];
|