Question

I upload the files alright. Only it turns out that, in my case, the starting directory is Public, and that results that the files are accesible by everybody when they should be in the directories that are protected by previous authentication, that is, under App.

So, when I do this:

$file = Input::file('fichero');
$destinationPath = 'uploads/folder';
$file->move($destinationPath);

// Create model
$model = new Model;
$model->filename = $file->getClientOriginalName();
$model->destinationPath = $destinationPath;

The file is saved in here: localh.../myweb/public/

and that is outside the App parent folder where all my application files are.

I can imagine that the fact that is going to that directory is because it is taking the default in the configuration file, which is localhost/laravel/public/index.php/

so, writing something like

$file->move(base_path().'/uploadfolder/subdirectory/', $newname);

will start from what is fixed as base_path, but the base_path needs to be something like localhost/mywebname/public.

So, how do you write the path so that it goes to directories under App and not under Public?

I hope I am not asking a dumb question, but I have been trying for days and I have read the 3 related queries in here.

thank you

Was it helpful?

Solution

You may use:

app_path() // Path to the 'app' folder
app_path('controllers/admin') // Path to the 'app/controllers/admin' folder

This will return you local file system path, you should put your uploaded images in public/... folder.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top