Support the ongoing development of Laravel.io →
posted 11 years ago
Forms

I have a form that accepts a file that I would like to move to my other server for storage. Since I'm using Laravel, it should be a piece of cake using it's built in SSH tools right? Well, either I'm doing something wrong or it's not working.

I have an uploaded file stored in a variable. I set up my SSH connection successfully and ran some test commands to check the connection. It all went well. Now I need to move my file to my other server using laravel's SSH::put().

SSH::put($map['image']->getRealPath(), '/var/www/html/site/public/tests');

This runs without any errors so I go check to see if the file exists there and I found nothing. To verify it is a file I'm moving, a dump on $map['image'] shows:

object(Symfony\Component\HttpFoundation\File\UploadedFile)[9]
  private 'test' => boolean false
  private 'originalName' => string 'vKK0Thw.png' (length=11)
  private 'mimeType' => string 'image/png' (length=9)
  private 'size' => int 23774
  private 'error' => int 0

Is there anyway to check when the upload is successful? I would like to display a message when the file gets transferred. I'm also using SSH keys to authenticate my server if it means anything using root.

Once again, the connection is fine, it just isn't uploading the file to the server. No errors.

Last updated 3 years ago.
0

A colleague and I had a similar situation where there was no error but the file just didn't show up on the server we were putting to. It turned out that the second argument to put() needed to be an exact file name rather than just a path. (I.e. instead /var/www/html/site/public/tests, you need /var/www/html/site/public/tests/myremotefilename). The documentation at https://laravelcollective.com/docs/master/ssh#sftp-uploads doesn't make that clear in my opinion.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

davidxd33 davidxd33 Joined 29 May 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.