samedi 27 mai 2017

Laravel - How to change upload file path

I need to upload images to folder project images.

My project structure folder in share host is this:

- css
- images
- fonts
- js
- laravel-code
-.htaccess

Inside laravel-code folder are the remaining files. The site work well, show images well but when i upload a new image it save the image in laravel-code/ and create this folders public/images ...

I want to save images in image folder at root directory.

How can i do that? When i do an upload file i detect if it was a pdf or other file, if it was pdf saves file on storage folder, if it other file(images) save in images folder. This is my code... i think i cannot use public_path

if (false === stripos($name, '-pdf')) {
    $basePath = trim(public_path(), '/');
    $newPath = trim(public_path('images'), '/');
} else {
    $basePath = trim(storage_path(), '/');
    $newPath = trim(storage_path(), '/');
}

Thank you



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire