CTOlet / yii2-attachments

Yii2 extension for uploading and attaching the files to the models
66 stars 57 forks source link

How can I use the file in a controller? #6

Closed philippfrenzel closed 9 years ago

philippfrenzel commented 9 years ago

e.g. I wanna open a word file (attachement) and then wanna replace stuff inside to deploy to user?

Thanks Philipp

CTOlet commented 9 years ago

I have not understood what do u want to do. Could u explain/give me an example?

philippfrenzel commented 9 years ago

I wanna do this:

http://phpword.readthedocs.org/en/latest/templates-processing.html

Which means:

´´´ $templateProcessor = new TemplateProcessor('Template.docx'); $templateProcessor->setValue('Name', 'Somebody someone'); $templateProcessor->setValue('Street', 'Coming-Undone-Street 32'); ´´´

Where Template.docx is the file I uploaded to a model, using your module;)

CTOlet commented 9 years ago

Now u can use

model->files[0]->path // for single file

or

foreach ($model->files as $file) {
    echo $file->path;
}

Is that all you need to?

philippfrenzel commented 9 years ago

Jep! exactly! ;) THanks a Lot