Create Attachment

How can i create a custom script which can allow users to upload their local files?

Hello,

You can prompt user with File Uploader dialog by initializing the frappe.ui.FileUploader. You may want to check the source code here.

Regards,

Ivan

1 Like

Any other simpler solution?

You can add “Attach File” field and you can make them mandatory.

That solution isn’t acceptable, i want one for custom script.

Hello,

Try using new frappe.ui.FileUploader().

P.S. Be respectful about other people giving an answer.

Regards,

Ivan

1 Like

Ok, i’m sorry for those words. Thanks a lot.

1597329389(1)
i mean how i can change the “Attach” button to a link.

Hello,

When you are using attach button, it will automatically be changed to link. However, you can also change it by setting it through properties. E.g. self.attach = '/files/example.txt'

Regards,

Ivan

Where can i access the property for attach button?

Hello,

Check the fieldname of the Attach button under your DocType definitions.

Regards,

Ivan

1 Like

Is it in the option or fetch?