1

I want to implement a file upload in my Yii2 application. This should be possible via Web and Console command.

Is there a helper in Yii2, so I can use the same implementation? (I started with yii\web\UploadFile for the web frontend and realized that I can't use that for the console command)

The yii\web\UploadFile class is designed to work with ActiveForm, or more specifically with the $_FILES content.

5
  • How you want to upload file with console? Just copy/move the file from one place to another? Commented May 21, 2014 at 16:58
  • I was hoping there is a helper like yii\web\UploadedFile, which can be used for console commands (Yii console commands!), but I guess that is not the case. Commented May 26, 2014 at 8:47
  • 1
    UploadedFile work with $_FILES array, which get data from HTTP POST. So, you cannot use UploadedFile directly to work with CLI. As variant, you can try to use curl Related question. Commented May 26, 2014 at 9:36
  • Yes I indicated that in the initial Post. Ok, no problem to find a way, but thanks anyway for your comments. Commented May 26, 2014 at 13:41
  • may be you can try run a script with input as file path to mv file from source folder (input) to destination folder. Commented Jan 27, 2015 at 7:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.