Support the ongoing development of Laravel.io →
Configuration Input Architecture
Last updated 2 years ago.
0

Perhaps change $path as below (add trailing slash):

$path = public_path().'/uploads/';

and then remove the slash that you added here:

Video::create([
    'name' => $filename,
    'path' => $path. $filename,
    'duration' => $file->getSize()
]);
Last updated 2 years ago.
0

Well the problem is the public_path function is the one that returns the /home/vagrant/code/webtv/public, the upload folder is just a directory I've added to put all my uploaded files so ^^

but thx anyway for the headsup ^_^

Last updated 2 years ago.
0

Hi, I'm not sure I understand.

If public_path function returns /home/vagrant/code/webtv/public - and then you append the path with '/uploads/', then when you move the file to $path, it goes in /home/vagrant/code/webtv/public/uploads/ which should then be accessible through $path. $filename

If you wish the uploaded file to be accessible from /home/vagrant/code/webtv/public/ then just change the following like so:

$path = public_path().'/';

Or am I missing something :)

Last updated 2 years ago.
0

No, can't do that because /home/vagrant/ is a fictive directory generated by Vagrant only to simulate the virtual machine !! It's just mapping files so when it requestes /home/vagrant/code/webtv/public well that means through Homestead config, it redirects to /wamp/www/Homestead/Code/webtv/public but then again for the upload path, it doesn't redirect !!

I hope I did explain the problem clearly this time ^_^ ?

Last updated 2 years ago.
0

Ah, I understand your problem now.

You are storing the path from your homestead VM in the database and using the same database in the live site or wamp?

In that case, use relative url to uploads folder maybe:

Video::create([
    'name' => $filename,
    'path' => "uploads/$filename",
    'duration' => $file->getSize()
]);

Then you can link to file within a view like:

URL::asset("uploads/$filename")

or maybe in blade like:

{{ link_to("uploads/$filename", 'Link') }} 
Last updated 2 years ago.
0

Try pointing your host file for homestead.app to your Homestead VM's IP (defaults to 192.168.10.10) instead of 127.0.0.1

I had a similar issue with an image manipulation method throwing a stack trace for "failed to open stream" in my Homestead environment. The confusing thing was that it worked in both production and on my teammate's VM running Laravel on a non-homestead box.

Homestead and Laravel are working appropriately. I just had to point homestead.app to the actual VM doing the hosting of my web application instead of pointing it to a specific port that wasn't being added or appended into the realpath of the upload.

Now that my homestead.app points to the VM's IP and not localhost, I no longer have to add the port 8000 nonsense to the url. I navigate directly to http://homestead.app and it works harmoniously.

Hope this helps!

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

minedun6 minedun6 Joined 30 Jun 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.

© 2024 Laravel.io - All rights reserved.