0

I had a web page where the user could upload pictures and then draw on it. All the drawing stuff are programmed in javascript.

After a new release, we want to provide to the user a specific set of images via the url.

By exemple : www.mysite.php?UID=encrypted.ID.of.folder.stored.server.side

And the server side will give to js the pictures to use.

My question is : In which format should I send the pictures to the JS functions to treat them exactly like from a filePicker ?

My PHP looks like this

<?php

    ini_set('display_errors',"1");
    $UID = $_GET['UID'];
    $path = scandir('./images/'.$UID);

?>

My OLD js to works with the images

<div id ="drop-box-overlay"></div>

document.getElementById("drop-box-overlay").addEventListener("drop",onDrop, false);

function onDrop(evt) {
var files = evt.dataTransfer.files;
}

//files is used in others functions but keep this format.

I want to retrieve var file by my PHP function. Is it possible ?

Atnaize
  • 1,766
  • 5
  • 25
  • 54
  • 1
    Your question is not clear. JavaScript does not have an API to work with images in any format. JavaScript CAN manipulate Canvas element, and read/write individual pixels there when needed. And Canvas accepts any images that the browser can read. – Alex Jan 29 '16 at 15:51
  • _"My question is : In which format should I send the pictures to the JS functions"_ What is `js` expecting ? Can include portions of `js` which receive data from `php` ? How is request made to `php` or URL at `html` document ? – guest271314 Jan 29 '16 at 15:52
  • You have to look into javascript code, but if - as you say - «the user could **upload** pictures and then draw», you have to pass the url of the file on server. – fusion3k Jan 29 '16 at 16:14
  • So, I think the files aren't uploaded (see [here](https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer)). The `files` are local files, so I think you have to let download files to client (but it sounds very ugly...) or modify your javascript more deeply than on var `files` – fusion3k Jan 29 '16 at 18:53

0 Answers0