Hello,
I wanted to ask if anyone knows how to set the uploaded image file name to something more unique, like date/time stamp, when the file is uploaded.
Thank you
Hello,
I wanted to ask if anyone knows how to set the uploaded image file name to something more unique, like date/time stamp, when the file is uploaded.
Thank you
Re: Unique Image name on Upload
Hello,
Welcome to our Forum.
Yes you could use PHP date function and concatenate its output with your Image field.
You could also, instead of adding a timestamp to its name, set the {ID} field as Subfolder on the field configuration.
regards,
Bernhard Bernsmann
Re: Unique Image name on Upload
Hello Bernhard,
Thank you for your reply.
Could you show me an example of where would I set the {ID} as a subfolder, please?
Would it be on the Application Events?
Thank you
Re: Unique Image name on Upload
Hi!
When you click in the image field, there must be a option like : enable subfolder
you can chose yes and in the path put something like: /{Id}
I am not so sure, but i think when i set it up like this, the subfolder was not created according to the ID (when inserting the new record) because i think the image is uploaded before the row gets ID, so i generated a unique number in the form in onload event and used the unique number as the folder name…
Re: Unique Image name on Upload
Hi ishwor,
Thank you for your suggestion.
I tried to make your suggestion work, without success. Here is what I did:
I used sc_set_global($uid) on the OnLoad event. But then, when I put it in the subfolder name option and run the app, I get:
Parse error: syntax error, unexpected ‘.’, expecting T_STRING or T_VARIABLE or ‘{’ or ‘$’ in <my_files>_apl.php on line 2038
Do you have any suggestions?
Thank you
Re: Unique Image name on Upload
I can give you an example, you can try this,
create a field in the form by clicking “New Field” (don’t need to create in the table, just in the form) ex. Foldername
onLoad event: {Foldername} = strtotime(“now”);
In the image field–> Create Subfolder : Yes and Subfolder = /{Foldername}
The folder name should be the unix timestamp of the time when the form was loaded…
Something like this and hope it works…
Re: Unique Image name on Upload
Hi ishwor,
It worked like a charm.
Thank you very much.
Re: Unique Image name on Upload
Hi
It did not work for me, I created a new field in my form name Foldername. At the photo field of my form I set create folder yes and set folder name to {Foldername}. It didn’t create a subfolder of timestamp at “wwwrootscriptcasefile”
Also, If do this approach, the subfolder name will not be save to the database, hence, I still need to store the timestamp as the folder name to my database.
Re: Unique Image name on Upload
hi instead of creating a subfolder, (which it didnt work for me), how can I rename the uploaded image?
I am using Image - FileName Data type.