Replace type file by fixed url variable


<a onclick="call_menu(FILE, 'file_open');" href="#">Choose file...</a>


    this.file_open = function () {;
    }; = function () {
    document.getElementById("tmp").innerHTML = '';
    var a = document.createElement('input');
    a.setAttribute("id", "file_open");
    a.type = 'file';
    a.multiple = 'multiple ';
    document.getElementById('file_open').addEventListener('change', this.open_handler, false);

    //force click

In html to click “Choose file” runs the excerpt above javascript.

But now I need to be different, I must eliminate the option to choose file and put a variable that will receive a file (url) set / fixed.

“this.open_handler” is the function below:

this.open_handler = function (e) {
    var files =;
    for (var i = 0, f; i < files.length; i++) {
        f = files[i];
        if (!f.type.match('image.*') && f.type != 'text/xml')
        if (files.length == 1)
            this.SAVE_NAME ='.')['.').length - 2];

        var FR = new FileReader();
        FR.file =[i];

        FR.onload = function (event) {
            if (this.file.type != 'text/xml') {
                LAYER.layer_add(,, this.file.type);
                EXIF.getData(this.file, this.save_EXIF);
            else {
                var responce = FILE.load_xml(;
                if (responce === true)
                    return false;
        if (f.type == "text/plain")
        else if (f.type == "text/xml")

My goal is just to remove the front end button “choose file” and create a variable with a fixed value (containing the url of the file)

I thought the following:

I exclude the two functions: “” and “this.file_open”, then in the “this.open_handler” function, delete the loop for, but I do not know how to properly take the loop and insert the variable with the url fixed:

var urlmyFixedImage = "image.png";

I am a newbie with javascript

That code you’ve shown is working with a file someone has selected on their computer, are you wanting to change it to download a file from a server and then process?

It’s not possible to access images from a users computer in JavaScript without the file input and having them select it.

Thanks for your answer.

Currently the code open a file through the button to the user to choose the file.

Now I’m trying to put a still image that the server ( So when the user open the application image is already loaded

var urlmyFixedImage = "";

Forgive me for asking but is there a reason you can’t use <img src=""> for this?

I’m sorry I have not explained before.
The reason is that the JavaScript code is part of an image editor.
It is an application to paint the image

Ah right, perhaps this is what you’re after?

I think the best mechanisms you’ll find is to load an <img> or Image in javascript and to access whatever properties it exposes.

See this is the editor I’m using;

I simply want to eliminate the option “open…”, and load the application already has an open image to paint

Complete code javascript for " file" relating to open and save file:

I may be off the mark here, but this sounds a lot like what you are trying to do.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.