mbo's avatar
Level 3

How to upload a file to do spaces

Good day,

I have a form why user can upload files by ajax script. Currently the preload places the files on my local webserver. The connection with DO spaces works.

But i can't get it working to rewrite the code below so it places the file on my do spaces.

I tried to work with:

storage::disk('do-spaces')->PutFileAs();

But i don't get it running with the code blowe (some else created this part).

Uploadcontroller:

/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store()
    {
      $inp = Input::all();
      $destinationPath = 'storage/xx/uploads/temp'; // upload path
      $extension = $inp["file"][0]->getClientOriginalExtension(); // getting image extension
      $fileName = Auth::id().time().$inp['file'][0]->getClientOriginalName(); // renameing image
      $inp["file"][0]->move($destinationPath, $fileName); // uploading file to given path
      return $fileName;
    }

Help would be appreciated.

thanks in advance.

0 likes
0 replies

Please or to participate in this conversation.