Updated 056 How to use the file field type to upload a file in JCB (markdown)

Amigo 2019-09-09 10:05:49 +02:00
parent 19a3b9f663
commit 063f4be359

@ -5,19 +5,21 @@
[00:00:00](https://www.youtube.com/watch?v=o482sK4DxkM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m00s)
(_Click on these time links to see Youtube video_)
We want to add a file field to a component and upload a file. I'm going to use this Demo component. It got a few Admin Views, we've got the area Look. I got a Site View, Looks and Looking. I'm going to add this field to the Look Admin View. I first need to create the field [00:00:32](https://www.youtube.com/watch?v=o482sK4DxkM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m32s) and we need to look at the steps that will need to implement. Currently JCB doesn't out of the box address this. We might think of doing this maybe in the future but because of some of the security risks, it's best you do this yourself. [00:00:54](https://www.youtube.com/watch?v=o482sK4DxkM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m54s) Because then at least you're under control and the risk is really yours and not put anyone else at risk.
We want to add a file field to a component and upload a file and are going to use this Demo component. It got a few Admin Views and the area 'Look'. There is a Site View, 'Looks' and 'Looking'. I am going to add this field to the Look Admin View. First, the field needs to be created and we need to look at the steps that need to be implemented.[00:00:32](https://www.youtube.com/watch?v=o482sK4DxkM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h00m32s) Currently, JCB does not out of the box address this. We might think of doing this maybe in the future but because of some of the security risks, it is best you do this yourself because then at least you are under control.
### Fieldtypes - File - Shows attributes, values, some descriptions, info
[00:01:06](https://www.youtube.com/watch?v=o482sK4DxkM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m06s)
So you're uploading a file. The Fieldtypes you want to use already exists. So if you go to Fieldtypes, there is a field called File. [00:01:32](https://www.youtube.com/watch?v=o482sK4DxkM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m32s) Everything in here was taken from Joomla's documentation. It shows you a whole lot of attributes, their values, some of the descriptions, but also shows you where to get more info on this. It's always good to do that. We are in Form field. [00:02:00](https://www.youtube.com/watch?v=o482sK4DxkM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m00s) Scroll down and there is the file field. It now has this new 'accept' parameter, which is a nice little extra which wasn't available when I first set it up. If yours doesn't have it, you will see that I [00:02:23](https://www.youtube.com/watch?v=o482sK4DxkM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m23s) have since added it. It's not showing up here.
If a file is uploaded the Fieldtypes you need to use already exist. So if you go to Fieldtypes, there is a field called 'File'. [00:01:32](https://www.youtube.com/watch?v=o482sK4DxkM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h01m32s) Everything in here was taken from Joomla's documentation. It shows you a whole lot of attributes, their values, some of the descriptions, but also shows you where to get more info on this. It is always good to do that. We are in Form field. [00:02:00](https://www.youtube.com/watch?v=o482sK4DxkM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m00s) Scroll down and there is the file field. It has this new 'accept' parameter, which is a nice little extra which has not been available when I first set it up. If yours does not have it, you will see that I have since added it. It is not showing up here.
### Adding New Attributes
[00:02:30](https://www.youtube.com/watch?v=o482sK4DxkM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h02m30s)
I might as well add it now. Under size, let's add that new attributes. So it's 'accept', the value I'm going to leave it to be in 'image' and can be changed. Let's give it some information as regarding description. Copy that and place in here(see video). We got this new attribute set. Those of you running the latest release of JCB, might already have this there. It only gets added if you do a fresh install. It doesn't update the database with these values. [00:03:15](https://www.youtube.com/watch?v=o482sK4DxkM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m15s) Save and close. We got a file types set.
I might as well add it now and place it under 'Size', and add that new attributes. Select 'accept', the value and to leave it to be in 'image' and can be changed.<<<<<<<<<<
Let's give it some information as regarding description. Copy that and place in here(see video). We got this new attribute set. Those of you running the latest release of JCB, might already have this there. It only gets added if you do a fresh install. It doesn't update the database with these values. [00:03:15](https://www.youtube.com/watch?v=o482sK4DxkM&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h03m15s) Save and close. We got a file types set.
### Beginning Of Setting Up The File Field Type