hi community ,
i’m trying to upload a picture or file before saving the doctype ,
i have this scenario:
-
save the pic to my public/files , with a name i made unique (self.name+.png)
-
make new file and pass the name to it.
attach_image = frappe.get_doc({
“doctype”: “File”,
“file_name”: name,
“file_url”: path + name,
“folder”:“home”
}) -
set the path to the attach image after_insert with update database .
def after_insert(self):
img_path = “/files/” + self.name + “.png”frappe.db.sql("""update `tabSlash` set barcode = %s where name = %s""", (img_path, self.name)) frappe.db.commit()
(1)step is the problem
for now i can do it if put the pictures manually to public/files folder
i wonder if there is a way to put file to public/file folder when the doctype is not save yet !