File Upload From Website

Hi,

I am creating some user as “Website User”. They have individual profile view and they can change their profile picture. Now there must have an attachment option. But how can i upload attachment file. Is there any way to upload image from website.

Thanks…

Hello,

Please ask your customers to update image and id on Gravatar. If user’s email id and image is found on Gravatar, it will be updated in his/her ERPNext account as well.

Thanks for replay umair,

It’s okay now. But i was create a new doctype for store user document. Users can upload document screenshot. That’s why i need the script.

Thanks…

We cannot write scripts for you, but if you are doing something we are happy to help out.

I don’t need the script. I want to know how can i do this in frappe framework.
Which codes i can apply.
Please give me a suggestion about this.

Hello,

Can anyone explain how can i do this in frappe framework? is there any way to do this in frappe? if it not done by frappe framework, i will try row python code.

Thanks…

I don’t know if i understand correctly your question, but here it is some ideas:

  1. You can use the doctype attachment.

  2. or… you can use javascript like this to send your picture to the server:

    frappe.call({
    “method”: “uploadfile”,
    args: args,
    callback: function(r) {
    if(!r._server_messages)
    msgbox.hide();
    if(r.exc) {
    // if no onerror, assume callback will handle errors
    opts.onerror ? opts.onerror(r) : opts.callback(null, null, r);
    return;
    }
    var attachment = r.message;
    opts.callback(attachment, r);
    $(document).trigger(“upload_complete”, attachment);
    }
    });

see this link: frappe upload.js

When you upload, the server return with the path where he put the picture… The picture will be put in sites/your database name/public then, i think, if you use that path in a link you get back the picture. I don’t test it, but some thing like this will do…

You can test uploading the picture then in the browser put the link and see if you get back the picture… or put some picture directly in sites/your database name/public and in the browser try to get that picture, if this work then you can use the second option above.

If you use the option 1) then you can get the picture back with the same procedure i just explain.

1 Like

hi @luisfmfernandes I have tried to implement the file upload here is my code.

frappe.call({   
		    "method": "frappe.client.set_value",
                    "cmd": "uploadfile",
                    "args": {
                            "filename": "somename.txt",
                            "doctype": "doctype",
                            "fieldname": "fieldname",
                            "docname": cur_frm.name,
                            "filedata": data,
                      
                    },
                    callback: function (r) {
                        console.log(r)
                    }
                }); 

but the frappe call is not working

What you need todo is to enable “Allow Guests to Upload Files” under system setting

1 Like