#Am unable to upload images with laravel app

48 messages · Page 1 of 1 (latest)

versed fern
#

Project ID: 17cc2546-a50b-4c61-b4e2-f665e56c4750
This is first time using laravel for backend on railway, when i attempt to upload an image it seems to get destroyed, like i do not have permission to do so

grim tendonBOT
#

Project ID: 17cc2546-a50b-4c61-b4e2-f665e56c4750

hasty frigateBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

sterile gorge
#

413 or something right?

versed fern
#

yes so it seens

sterile gorge
#

can you confirm the error code for me?

versed fern
#

my deployment log shows

sterile gorge
#

i mean when you try to upload an image

versed fern
#

the form goes through and i get that error in the logs when the image tries to render

sterile gorge
#

please review the network logs in the dev tools during an image upload

versed fern
#

there is no error during the upload

#

only a 404 when there image is attempted to be previewed

sterile gorge
#

where are you saving the image?

versed fern
#

storage/app/public/

sterile gorge
#

are you using a volume?

versed fern
#

no

sterile gorge
versed fern
#

how do i set it up with laravel

sterile gorge
#

you save the files to the volume during upload

versed fern
#

in my code i use Storage::put(public/...) to store files, so do i have to mount my volume to /public ?

sterile gorge
#

try mounting the volume to /app/storage/uploads and then save the images to ./storage/uploads

versed fern
#

laravel file system looks like app/storage/app/public

sterile gorge
#

it was only a suggestion based on what has worked for other people in the past, you are free to mount the volume to whatever path works best for you

versed fern
sterile gorge
#

you would still need a volume no matter what, otherwise any file you uploaded is wiped when you make the next deployment

versed fern
#

yes, the issue am now facing is with the NIXPACKS_BUILD_CMD env values

#

it seems when i add multiple build commands i run into a build error, i tried adding "NIXPACKS_BUILD_CMD =npm run build && php artisan storage:link" just to confirm that the php artisan storage:link was the issue and the images did show, but other commands are not executed, when i added all the necessary build commands i run into an error

#

when i remove the env everything is added except the php artisan storage:link

sterile gorge
versed fern
#

am finding it difficult to apply this

sterile gorge
#

let's see what you have so far

scarlet ermine
sterile gorge
#

that's correct, volumes are not mounted as overlays

scarlet ermine
sterile gorge
#

all volume access has to be done via the service it's attached to

versed fern
# sterile gorge let's see what you have so far

[phases.setup]
nixPkgs = ['php' 'nodejs' 'composer']

[phases.install]
cmds = ['composer install', 'npm install']

[phases.build]
cmds = ['npm run build', 'php artisan optimize:clear']

[start]
cmd = 'php artisan storage:link'

#

it looks like its totally ignoring the file when building

sterile gorge
#

why do you think that?

versed fern
#

beacuse its not linking the storage

sterile gorge
#

does the build table at the top of the build logs reflect correctly with what you have set there?

versed fern
#

it looks like it doesnt

sterile gorge
#

did you name the file correctly? nixpacks.toml

versed fern
#

have named the file correctly and now the app as failed to build

#

Error: Failed to parse Nixpacks config file nixpacks.toml

sterile gorge
#

you dont need to specify every phase, just the phase you want to change

versed fern
#

My nixpacks.toml file
[phases.build]
cmds = ['npm run build', 'php artisan optimize:clear','php artisan storage:link']

#

the storage is now linked, thank you

sterile gorge
#

no problem!