Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
file_replace() in mod_file_upload (txp_file)
I was thinking of starting to work on a plugin that would allow users to replace files (Is there one out there already? I’ve seen a mod but I couldn’t find anything in textpatter.org).
Anyway I noticed that txp_file already has a file_replace function. Manfre, was this just never fully finished? Anyone else know anything about it? It seems to have been there since the initial import of mod_file_upload.
Last edited by hakjoon (2005-07-26 20:32:41)
Shoving is the answer – pusher robot
Offline
Re: file_replace() in mod_file_upload (txp_file)
I use a modified file.php from Greenrift which you can find in the Announcement forum. It does mean you will have to do a “diff” if the file.php is changed in the main code though. Not that it happens too often. :) I’m not sure what the position is with regard to including this into the base code. You can read what was said around that link above.
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: file_replace() in mod_file_upload (txp_file)
Ahh thank you. I was having a hard time finding that thread. I’ll see how hard it would be to turn that into a plugin. Greenrift’s stuff is normally pretty easy to follow. That way it can be available without mods right now and the guys can decide if they want to incorporate it later. Hopefully by then most of the desired options will have been sorted out too.
Shoving is the answer – pusher robot
Offline
Re: file_replace() in mod_file_upload (txp_file)
hakjoon – you can now replace an existing file without that hack. If you upload your new file via FTP and whilst you are there delete the file you want to replace, then go into the file tab you will find that the old file is reported as “missing”. Click on it to go to the upload screen and you have 2 options; browse for a new file or select an existing file. Use the existing file box to pick the file you have just uploaded and it will be saved in the old files place retaining the same id and download counts. You may need to go back to the upload screen if any “details” need changing.
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: file_replace() in mod_file_upload (txp_file)
That works pretty well. Thanks for the tip.
Shoving is the answer – pusher robot
Offline
Re: file_replace() in mod_file_upload (txp_file)
I thought I submitted a patch that re-enabled the replace feature a few months back. I’ll double check and at the very least, submit it again.
Offline
Re: file_replace() in mod_file_upload (txp_file)
Go for it Manfre. I don’t think it will get into 1.0 though. There does appear to be a way of replacing existing files in a default install as I detailed above though it would be difficult to “stumble” upon it. Did Greenrift come up with anything?
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: file_replace() in mod_file_upload (txp_file)
FYI: Looking at the most current revision, and the file I uploaded, there is one line that is different:
Find line #219, just after that add the following:
/* Replace File Hack */ $form .= tr(td(upload_form(gTxt('upload_file'),'upload','file_replace',$id)));
(it should be right above a } else {
statement).
Then change Line #365 to:
$newpath = build_file_path($file_base_path,$name);
(previously the $name
part was $filename
).
Then add:
safe_update('txp_file',"filename='".mysql_real_escape_string($name)."'","id = $id");
Just after Line # 380 or so (there will be a } else {
and then file_set_perm($newpath)
. Put it in between those two.
That will do the trick. Also, since txp_file isn’t changed much, those changes should happily go along with svn updates (or have on one of my installs). It would be nice if these changes were included, because I’ve found replacing files really useful.
Last edited by greenrift (2005-08-05 22:25:39)
Offline
Re: file_replace() in mod_file_upload (txp_file)
Thanks for that Greenrift. :) This is still the one big thing missing from the existing file facility but the way things are at the moment I don’t think it stands much chance of being added before 1.0 comes out, though these are really quite minor code changes. A bit like the if_section mods that Mary did for me over in the “Feature Requests” forum. Two minor mods and a lot of extra flexibility. Seems like a fair swap to me. ;)
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline