0

I have a fully functional file upload system on my page, where I can upload image files. Now i want to create a button that uploads a spefific image(file), which is embedded on my page and which has a specific ID, without opening the actual file upload window of the browser.

The image on my page:

<img id="uploadme" src="https://placeimg.com/200/200/tech?t=1531087926475">

Just like this: enter image description here

Peter Griffin
  • 67
  • 1
  • 9
  • 1
    Welcome - please review the [ask] documentation. What research have you done? And how does a user pick the file if the file upload window is not opened? – random_user_name Jul 08 '18 at 22:24
  • 2
    So do you want to upload the already uploaded image again? – Amr Elgarhy Jul 08 '18 at 22:24
  • The user doesn't pick the file. The file is the image which is already embedded in the page – Peter Griffin Jul 08 '18 at 22:25
  • @AmrElgarhy Yes ;-) – Peter Griffin Jul 08 '18 at 22:26
  • 3
    So it is already on your server, take it from there, why the work around? – Amr Elgarhy Jul 08 '18 at 22:27
  • 1
    You can drag the file to the upload input if you dont want to open the file upload window. – bdalina Jul 08 '18 at 22:27
  • The problem is, that the image is only generated temporarily, so the user needs to upload it in order to save it. Thats why i need this solution – Peter Griffin Jul 08 '18 at 22:29
  • I still can't understand the process here, but this might help: https://stackoverflow.com/questions/1110246/how-do-i-programmatically-save-an-image-from-a-url – Amr Elgarhy Jul 08 '18 at 22:30
  • Thats not what im looking for – Peter Griffin Jul 08 '18 at 22:41
  • If the data for the image is already on the page, but not on the user's filesystem, I would not use a file type input. You cannot easily modify the behaviour of a file type input due to security considerations. Consider uploading via a hidden input, setting the value via js as the base64 encoded image data. – ZombieTfk Jul 08 '18 at 23:16
  • Look for [request.js](https://gist.github.com/jfsiii/3739251) to convert an image URL into a base64 encoded... Which you could save. – Louys Patrice Bessette Jul 08 '18 at 23:48
  • *"generated temporarily"* as in what? Does fetching the image again from the same src actually return a new image every time? If not, why don't you just send the url to your server and fetch it from there? Otherwise, the best would be to actually fetch it as Blob through AJAX, and display it from a BlobURI on your client, then send the Blob through AJAX. [It is *possible*](https://stackoverflow.com/questions/47119426/) to do what you are asking for in newest versions of Chrome and Firefox, but since you only want it for UI purposes, it is still just better to simply build up your own UI. – Kaiido Jul 09 '18 at 02:33

0 Answers0