-3

I'm using type="file" in HTML, to get images from my computer.

when i join my image, it only shows my image name. Example:

I have a image named "folder/image1.jpg", but when i submit it only shows "image1.jpg".

And when i submit all the form, the image goes to my database whithout the folder name.

I need the folder name because whitout the folder name, my database cant recognize the images.

i'm using this code

<input type="file" name="fileUpload" />
user2744048
  • 111
  • 1
  • 2
  • 7

1 Answers1

2

The file path isn't submitted with the file, because that would give personal information that the server shouldn't know. Only the file name is sent.

The usual solution to recognize images (or more generally files), for example to avoid duplicates, is to compute a low-colision hash of the file content and to store this hash (you'll probably want this hash to have a unique constraint in your database).

Denys Séguret
  • 372,613
  • 87
  • 782
  • 758