Control overwriting file when uploading to the File System with uppy
Posted: Thu Feb 16, 2023 12:55 pm
Hello there!
I'm using nuBuilder since a few weeks and I think it's an amazing software for designing database applications - especially for advanced, yet non-professional programmers. So first of all, thanks a lot to the developers for creating and providing this great (open source!) software!
At the moment, I'm trying to implement a server-side file management system. In my browse and edit form I've created an upload field with uppy. With customization of the uppy script and the NUUPLOADE script, a file gets uploaded, renamend and saved on the file system. The (new) file name is beeing retrieved after upload with a nuOnFileUploadComplete function and set with JavaScript into a form field (and saved to the database). With HTML the uploaded file can be displayed or downloaded. So far, it works like a charm.
My problem now is that an existing file gets overwritten on upload without any warning or confirmation - this is too risky. My idea was to set a "overwrite" checkbox in the browse and edit form and send this value as metadata of the uppy script to the NUUPLOADE script. The script should check if a corresponding file exists with File_exist () function and - if yes - then check whether overwrite is allowed with the value from the "overwrite" checkbox. This doesn't work, because (boolean) non-string value aren't transported via POST methods - again I've learned something.
Then I tried to create a hidden form field (only client side, not in database) with a text "allowed" / "permitted" that is set with JavaScript of the checkbox. This text value should be transported via uppy script as (hash) variable. But apparently, values must also be saved to the database first, before beeing available as hash cookies, and so this doesn't work either.
Third idea was to set a form property "fileoverwrite" with "allowed"/"permitted" via checkbox and transport this with a hash variable in the uppy script. Basically, this works but the value "allowed" is only transported after checking-unchecking-checking the checkbox - I tried this with nudebug() variable in the NUUPLOAD script (however, in form info the variable are available without double/triple clicking...) .
Now I'm wondering what to do next... does anyobody have an idea how to set an "overwrite allowed" value in the browse and edit form and transport it to the PHP script when uploading a file with uppy? Is there maybe another way to set and send overwrite permissions I haven't considered yet? Can I maybe add metadata with an additional uppy form field? In fact, I'm not really familiar with this plugin...
I'm looking forward to your ideas and support!
I'm using nuBuilder since a few weeks and I think it's an amazing software for designing database applications - especially for advanced, yet non-professional programmers. So first of all, thanks a lot to the developers for creating and providing this great (open source!) software!
At the moment, I'm trying to implement a server-side file management system. In my browse and edit form I've created an upload field with uppy. With customization of the uppy script and the NUUPLOADE script, a file gets uploaded, renamend and saved on the file system. The (new) file name is beeing retrieved after upload with a nuOnFileUploadComplete function and set with JavaScript into a form field (and saved to the database). With HTML the uploaded file can be displayed or downloaded. So far, it works like a charm.
My problem now is that an existing file gets overwritten on upload without any warning or confirmation - this is too risky. My idea was to set a "overwrite" checkbox in the browse and edit form and send this value as metadata of the uppy script to the NUUPLOADE script. The script should check if a corresponding file exists with File_exist () function and - if yes - then check whether overwrite is allowed with the value from the "overwrite" checkbox. This doesn't work, because (boolean) non-string value aren't transported via POST methods - again I've learned something.
Then I tried to create a hidden form field (only client side, not in database) with a text "allowed" / "permitted" that is set with JavaScript of the checkbox. This text value should be transported via uppy script as (hash) variable. But apparently, values must also be saved to the database first, before beeing available as hash cookies, and so this doesn't work either.
Third idea was to set a form property "fileoverwrite" with "allowed"/"permitted" via checkbox and transport this with a hash variable in the uppy script. Basically, this works but the value "allowed" is only transported after checking-unchecking-checking the checkbox - I tried this with nudebug() variable in the NUUPLOAD script (however, in form info the variable are available without double/triple clicking...) .
Now I'm wondering what to do next... does anyobody have an idea how to set an "overwrite allowed" value in the browse and edit form and transport it to the PHP script when uploading a file with uppy? Is there maybe another way to set and send overwrite permissions I haven't considered yet? Can I maybe add metadata with an additional uppy form field? In fact, I'm not really familiar with this plugin...
I'm looking forward to your ideas and support!