A
A
adiafora2020-08-20 16:27:04
Yii
adiafora, 2020-08-20 16:27:04

How to upload file not from form in Yii2 using UploadImageBehavior?

I am using a package mohorev/yii2-upload-behaviorto upload files and link them to a model. Everything works correctly if I upload a file through a regular form using the POST method.

But now I need to receive a file from a remote server via ftp and upload it to my server. I get the file, but how, using UploadImageBehaviorsave and link the file to the model?

Because UploadImageBehavior works from under behaviors, then I somehow have to simulate the corresponding event? How exactly?
How exactly to specify UploadImageBehavior that the file will be loaded not from $_FILES, but along the path from the server (I save the file on the server with ftp first)?
Or should I somehow "fake" the UploadedFile?

I will be glad to any hints.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question