Drupal: File upload not overwriting original file.

quikwallace
quikwallace used Ask the Experts™
on
I have a content type that has a field that will take pdf and .doc/docx files.  I am use the file field.  Here is what I just noticed and have not been able to fix today.  

When say my file testfile.pdf is uploaded and a say the user make an update to the file and uploads it again, instead of the original file testfile.pdf being overwritten, a second file, testfile_1.pdf is created.  

I don't see anything in the file upload gui that allows me to select overwrite instead of add another.  

Does anyone know how to accomplish this?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Drupal does this so you don't overwrite files. Revisioning wouldn't work without it, actually. There are a number of reasons why it was designed this way, but that's beyond the scope of this question (and probably something you don't want to know) :)

If you need to overwrite the file on a node, remove the file from the node, then upload the new version. The filename may or may not change (I'm not sure), but the referenced file on the node definitely will. In essence, you are overwriting the file on the node. It's just not changing the behind-the-scenes filenames.

There are ways to overwrite files if you really need to using hooks. I wouldn't recommend it, though, if you aren't familiar with Drupal internals in that respect. Bad things could happen.

I hope this helps at least a little.

Cheers,

Mike

Author

Commented:
you are apparently correct, though I swear I have been able to overwrite a file name before.  If I could, I don't remember how now.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial