changing the name on a binary upload

A place for users and developers of the Xataface to discuss and receive support.

changing the name on a binary upload

Postby wisni1rr » Thu Mar 01, 2012 1:02 pm

I was wondering how you could have the name of a file changed as it uploads?

For example:
I have a field that uploads a .pdf file to a directory on my server. I would like it so that it would rename the file using a field in my table so the new name would be $ID.pdf essentially.

The reason I ask is because if someone happens to upload a file that is named the same as another, it would overwrite the original .pdf file.

Thanks for taking the time to read my post!
wisni1rr
 
Posts: 107
Joined: Mon Feb 13, 2012 9:03 pm

Re: changing the name on a binary upload

Postby shannah » Thu Mar 01, 2012 1:22 pm

If someone uploads a file with the same name, it will rename the file being uploaded automatically by appending a numeric index to the name and/or incrementing it. It shouldn't overwrite when there is a collision.

As far as renaming it yourself, you could implement a beforeSave handler to rename the file and set the new name in the file field.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 15 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved