johndatserakis / file-upload-with-preview

🖼 Simple file-upload utility that shows a preview of the uploaded image. Written in TypeScript. No dependencies. Works well with or without a framework.

Home Page:https://johndatserakis.github.io/file-upload-with-preview

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Name attribute not present in sending request to server.

mirfanalikhanprofessional opened this issue · comments

Hi, I am having an issue that input element attribute name is not present in the dynamically generated field which is causing problems in the server side, then I tried attaching dynamically to it using the Custom JS it gets attached to the input element but still I can not receive the image on the server side, so could you elaborate how to work around with this, thanks for your help, your plugin has been a big help.

ok, now I have edited the plugin code to generate the name attribute dynamically, but that particular input field data is not being sent to the server. So can anyone tell me, that what is the issue, I can shared the changes done in the plugin code also, just needed to modify few lines.

Any update or suggestion @johndatserakis, regarding this problem.

Hey there - yea I've seen this in the past and it indicates that you are not sending the data to the backend in a way that will work. You should not need to pass the name manually.

I answered a similar question here recently. I'm not sure what backend you're using, but something like FormData on the frontend should allow everything to be passed properly.

I am using the FormData via an AJAX call to submit the form, before changing the plugin code to add the name attribute the problem still persisted. When I checked the raw request data on backend, it could be seen that image was not present, so that's why I took the approach of adding the name attribute but still I was not able to receive the image file. By the way, the backend is based on Laravel.

Hmm, interesting. Sorry I don't have a better answer for you now - I will mark this as something to look into on my end. Maybe I could stand-up a little demo app with a backend showing this working from soup to nuts. I'm just super booked right now, so sorry for the delay.

Closing for now - as I mentioned, this is more for frontend image handling. Perhaps one day I'll do a whole demo with a backend, but I won't be getting to that unfortunately in the near future.