Mark,
File.. gotta love it.
However. when using the Extract URL Plus in conjuction with File I found that File does not encode or change spaces to underscores in file names (hence Extract URL Plus can’t isolate a file name). This is unlike when uploading via EE Upload thta does change the spaces to underscores.
Perhaps File should make web safe names, or encode the space when uploading?
SAEF with EDIT
I am hoping to make a one stop thread for SAEF and Mark’s file extension.
1st. Change the mod.weblog_standalone.php file.
2nd. You will need add this javascript.
3rd. To get custom weblog fields to work in the SAEF, you have two choices. Either install solspace’s form helper plugin. Or use the field names from the database. If using the field names, go to CP Home › Admin › Utilities › Manage Database Tables › exp_weblog_data and click browse. At the top of each column is the name of the field for each entry. Notice both the id and ft. You need both for each custom field. You will use these field names for the names of your form elements. Example:
Continued on next thread
4th. To make an edit form that works with the file extension, you will need to add several more lines of code. Set the template to enable php. The two functions will give you the name of the file with extension and just the extension. Add the following code to the top of the template.
<?php
function get_filename($x) {
$filename = basename($x); // name of file with extension.
$result = explode('.', $filename); // $result[0] = file name, $result[1] = extension.
echo $result[0].'.'.$result[1];
}
function get_ext($x) {
$filename = basename($x); // name of file with extension.
$result = explode('.', $filename); // $result[0] = file name, $result[1] = extension.
echo $result[1];
}
?>
5th. Lets pretend that the short name for the custom field is {attachment}. You will use the get_filename function for the name of the link. The get_ext will be used to get a image for the type of attachment. Your code will look like this:
This should work for edit forms. I have not tested this out for preview.
File Protection
You can make Mark’s file extension work with Robin’s download lock module. Here are the instructions.
I’m coming across a really odd error with this extension.
When I post to a weblog with a file input, and I try to view it logged in as a superadmin, the page doesn’t render at all. No HTML, no nothing; its as though an exit() has been called. I can, however, view the post as a regular member or an anonymous user. If I disable the extension, I am able to view the post normally.
Anyone encountered this before? I’m using EE 1.5.2
It seems to happen when I upload any file. I just re-tested with an image. The settings are to upload the the directory set up in the File extension settings. The control panel works fine, the item gets uploaded to the appropriate directory. Its only on the frontend when logged in as a superadmin that the page does not render. As a regular user or anonymous one, I can see it just fine.
I duplicated the environment on my local machine. I started apache, loaded a problem page, and then shutdown the http server. Here’s the error log.
[Tue Jun 12 09:11:20 2007] [notice] Apache/2.2.4 (Win32) PHP/5.2.2 configured -- resuming normal operations
[Tue Jun 12 09:11:20 2007] [notice] Server built: Jan 9 2007 23:17:20
[Tue Jun 12 09:11:20 2007] [notice] Parent: Created child process 5088
[Tue Jun 12 09:11:20 2007] [notice] Child 5088: Child process is running
[Tue Jun 12 09:11:20 2007] [notice] Child 5088: Acquired the start mutex.
[Tue Jun 12 09:11:20 2007] [notice] Child 5088: Starting 250 worker threads.
[Tue Jun 12 09:11:20 2007] [notice] Child 5088: Starting thread to listen on port 80.
[Tue Jun 12 09:11:32 2007] [error] [client 127.0.0.1] PHP Warning: Missing argument 2 for file::fetch_setting(), called in C:\\www\\hood\\_admin\\extensions\\ext.file.php on line 728 and defined in C:\\www\\hood\\_admin\\extensions\\ext.file.php on line 812, referer: http://localhost/repository
[Tue Jun 12 09:11:32 2007] [error] [client 127.0.0.1] PHP Notice: Undefined variable: setting in C:\\www\\hood\\_admin\\extensions\\ext.file.php on line 828, referer: http://localhost/repository
[Tue Jun 12 09:11:32 2007] [error] [client 127.0.0.1] PHP Notice: Undefined variable: setting in C:\\www\\hood\\_admin\\extensions\\ext.file.php on line 837, referer: http://localhost/repository
[Tue Jun 12 09:11:32 2007] [error] [client 127.0.0.1] PHP Notice: Undefined variable: setting in C:\\www\\hood\\_admin\\extensions\\ext.file.php on line 840, referer: http://localhost/repository
[Tue Jun 12 09:11:32 2007] [error] [client 127.0.0.1] PHP Notice: Undefined variable: setting in C:\\www\\hood\\_admin\\extensions\\ext.file.php on line 843, referer: http://localhost/repository
[Tue Jun 12 09:11:32 2007] [error] [client 127.0.0.1] PHP Notice: Undefined variable: setting in C:\\www\\hood\\_admin\\extensions\\ext.file.php on line 846, referer: http://localhost/repository
[Tue Jun 12 09:11:32 2007] [error] [client 127.0.0.1] PHP Notice: Undefined variable: setting in C:\\www\\hood\\_admin\\extensions\\ext.file.php on line 849, referer: http://localhost/repository
[Tue Jun 12 09:11:32 2007] [error] [client 127.0.0.1] PHP Notice: Undefined variable: setting in C:\\www\\hood\\_admin\\extensions\\ext.file.php on line 852, referer: http://localhost/repository
[Tue Jun 12 09:11:32 2007] [error] [client 127.0.0.1] PHP Notice: Undefined variable: setting in C:\\www\\hood\\_admin\\extensions\\ext.file.php on line 855, referer: http://localhost/repository
[Tue Jun 12 09:11:32 2007] [error] [client 127.0.0.1] PHP Warning: Missing argument 2 for file::fetch_setting(), called in C:\\www\\hood\\_admin\\extensions\\ext.file.php on line 729 and defined in C:\\www\\hood\\_admin\\extensions\\ext.file.php on line 812, referer: http://localhost/repository
[Tue Jun 12 09:11:32 2007] [error] [client 127.0.0.1] PHP Notice: Undefined variable: setting in C:\\www\\hood\\_admin\\extensions\\ext.file.php on line 828, referer: http://localhost/repository
[Tue Jun 12 09:11:32 2007] [error] [client 127.0.0.1] PHP Notice: Undefined variable: setting in C:\\www\\hood\\_admin\\extensions\\ext.file.php on line 837, referer: http://localhost/repository
[Tue Jun 12 09:11:32 2007] [error] [client 127.0.0.1] PHP Notice: Undefined variable: setting in C:\\www\\hood\\_admin\\extensions\\ext.file.php on line 840, referer: http://localhost/repository
[Tue Jun 12 09:11:32 2007] [error] [client 127.0.0.1] PHP Notice: Undefined variable: setting in C:\\www\\hood\\_admin\\extensions\\ext.file.php on line 843, referer: http://localhost/repository
[Tue Jun 12 09:11:32 2007] [error] [client 127.0.0.1] PHP Notice: Undefined variable: setting in C:\\www\\hood\\_admin\\extensions\\ext.file.php on line 846, referer: http://localhost/repository
[Tue Jun 12 09:11:32 2007] [error] [client 127.0.0.1] PHP Notice: Undefined variable: setting in C:\\www\\hood\\_admin\\extensions\\ext.file.php on line 849, referer: http://localhost/repository
[Tue Jun 12 09:11:32 2007] [error] [client 127.0.0.1] PHP Notice: Undefined variable: setting in C:\\www\\hood\\_admin\\extensions\\ext.file.php on line 852, referer: http://localhost/repository
[Tue Jun 12 09:11:32 2007] [error] [client 127.0.0.1] PHP Notice: Undefined variable: setting in C:\\www\\hood\\_admin\\extensions\\ext.file.php on line 855, referer: http://localhost/repository
[Tue Jun 12 09:11:37 2007] [notice] Parent: Received shutdown signal -- Shutting down the server.
[Tue Jun 12 09:11:37 2007] [notice] Child 5088: Exit event signaled. Child process is ending.
[Tue Jun 12 09:11:38 2007] [notice] Child 5088: Released the start mutex
[Tue Jun 12 09:11:39 2007] [notice] Child 5088: Waiting for 250 worker threads to exit.
[Tue Jun 12 09:11:40 2007] [notice] Child 5088: All worker threads have exited.
[Tue Jun 12 09:11:40 2007] [notice] Child 5088: Child process is exiting
[Tue Jun 12 09:11:40 2007] [notice] Parent: Child process exited successfully.
Looking closer, the file in use may be a slightly older version (still 2.1.0). The site has been up for about a month. A fresh download seems to have solved the problem on my local machine for now. I’ll take a further look and keep you posted.
In regards to the output debugging, nothing is displayed on that page.
Mark, is there a possibility to access the filenames/-pathes like an array?
The idea is to upload a sequence of pictures (here: two), which then should be either switched via JavaScript/AJAX or where the second one will popup in a separat div on mouse click. But I can’t figure out how to access both pictures at once. Any ideas?
-Markus
an you maybe give an example of what you mean?
Sure. Lets try to keep it simple…
Right now I’m using two separate fields that are set to ‘file’: covermouseout and covermouseover. With JS, something simple as this is possible (and working great):
<img alt="Cover" src="{covermouseout}" onMouseOver="this.src='{covermouseover}';" onMouseOut="this.src='{covermouseout}';" border="1" />
However, with the files extension set to allow multiple uploads in one field named cover, I’d love to upload both images in one field and extract them somehow, e.g. using {cover[1]} or {cover[2]} or anything else with the same meaning. However, using the iteration {covers}…{/covers} seems only to give access to either the firt or the second file.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.