inertiajs/inertia-laravel

image upload help

mangga88d opened this issue · 2 comments

i am trying to store image to database, i encounter problem using inertia useForm. other things are fine for me for sending form. only file can not be send.
any help would be good
Screenshot at Mar 09 18-24-18
Screenshot at Mar 09 19-20-27
Screenshot at Mar 09 19-43-44
Screenshot at Mar 09 19-53-56
Screenshot at Mar 09 20-03-59
Uploading Screenshot at Mar 10 15-02-54.png…

Okay, let's get the basics out of the way:

  1. This is the repo for inertia-laravel. That is the backend bridge of the Inertia project. This repo has nothing to do with the frontend elements like useForm
  2. If you're having issues performing basic tasks in a project that has thousands of active users, 999,999 times out of a million, it's going to be a coding error on your part. GitHub issues are not the place to ask for coding assistance. They are for reporting issues with the code in the repo itself.

So, rather than be overly negative, here's some help:

form.product_images = productImages.value.push(file)

The JS push function returns the new length of the array you've just pushed to (see: MDN Array.prototype.push). So here, you're just saving an integer to form.product_images, not the files.

Push first, and then save productImages.value to form.product_images.

form.post only takes two params, (1) route (2) navigation options object. You need your onSuccess in the same object as preserveState.

Both Vue and Inertia have Discord channels which will be a more appropriate venue for coding help in the future.

Hi there,

Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:

However, this issue will not be locked and everyone is still free to discuss solutions to your problem!

Thanks.