Is it not true that these should be flipped?
// find the file and measure up..
$file = (substr($filedir,-1, 1) == '/' ? $filedir : $filedir.'/').$filename;
// magical unicorns, now with wings and pixie dust
$filename = basename($filename);
$tmp = array_reverse(explode('.', $filename));
$fileext = $tmp[0];
I was thinking that “find file and measure up” should be renamed “pixie dust” and then unicorns should come before pixie dust. I’ll try your latest, though. This has become quite the thread. Sort of…trippy.
The only reason I needed them flipped is due to how Mark Huot’s File extension outputs the content of its field, which is a whole path. If I use his extension to upload “masugadesign.vcf” (my vCard) to a file field, and put filesizer on it in the template, I get this error:
Error opening file: "/home/me/public_html/files/http://www.mysite.com/files/masugadesign.vcf"
But flipping those, so we get the basename first, I get the correct output, as seen in the attched pic.
And now, I think we’re done…at least for a few months. Thanks for all your help on this, Andy!
Is it possible to have a sort of “virtual” folder set in the upload preferences to use in the plugin syntax?
More specifically, I have a set of folders with MP3 files in them. Every year we move to using a new folder with that year label. So we have /2006, /2007 and now /2008. Is it possible to set the upload folder as the base folder that those year folders sit in and then program the back end to look deeper according to the year?
My initial syntax (that did not work) looked like this:
<a href="http://mysite.com/podcast/audio/{entry_date">Download Audio</a> » {exp:filesizer filename="{entry_date format="%Y/%m.%d.%y.mp4"}" upload_pref="7" decimals="1" zero_decimals="no"} {fs:file_extension}: {fs:file_size}{fs:size_unit} {/exp:filesizer}
The path in EE to download the file does work. But the Filesizer breaks, even though the error code shows the path perfectly. It just returns the error instead of delivering the file size.
Any ideas on whether this is possible? I am trying to avoid having a whole bunch of folders listed in the file upload preference. And to avoid a lot of conditionals in the back-end switching syntax/folders based on the year of the entry.
Here’s the error code:
Error opening file: “/path-to/htdocs/theaterchurch/subdomains/media/podcast/video/2007/12.09.07.mp4”
The actual file can be seen at http://media.theaterchurch.com/podcast/video/2007/12.09.07.mp4
By the way, I’m not really using EE to upload these files. I am using FTP. I am just trying to get EE to look at a base directory and then have filesizer look deeper within according to the entry_date variable. So it won’t matter that the path in EE’s upload prefs doesn’t go all the way to the directory where the files actually are because I am not using the upload feature to get them there.
Ok, I’ve looked into it, and I think it’s not working because you’re passing it a “folder/filename”. I want to give you the option to silence the error, but I don’t want to break how the plugin works for everyone else.
I can add a quickfix param called additional_path=”” where you can use {current_time format="%Y"} or whatever to make the paths a little less static, would that do you any good?
I’ll also add silence=”yes”, to mute the error message.
edit: wrote too fast, forgot to think twice.
ExpressionEngineer Thanks for all your help on this. I really need to get something rolling on this fairly quickly. Obviously, I don’t mean to be pushy. After all, your helping me out a ton and I love the elegance of your solution! But I would need that tweak before it will work for me.
If I need to look another direction, let me know so I can try to get a solution in place. If you think it will only be a little more time, I’d love to wait it out. I just need an update. 😊
Thanks!
Sorry about the delay. I’m working around the clock on multiple things right now and have very limited time to look at this (no time at all really), but I can give it a proper whirl after the weekend, or if anyone else want to download the code and mod it for you that’s perfectly fine with me.
Let me know if you need me to look at it after the weekend.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.