Solved

Drupal: File upload not overwriting original file.

Posted on 2014-01-12
2
825 Views
1 Endorsement
Last Modified: 2014-01-26
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?
1
Comment
Question by:quikwallace
2 Comments
 
LVL 12

Accepted Solution

by:
junipllc earned 500 total points
ID: 39775826
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
0
 

Author Comment

by:quikwallace
ID: 39810081
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.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
WordPress Themes 10 34
converting numbers with php 3 27
phpmailer in WHILE loop - weird results 10 27
Make custom query_posts look show the excerpt only 9 24
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now