Would there be any way to add a progress bar (eg swfupload, fancyupload), or animated uploading gif for larger files?This isn’t really in the scope of this extension. I basically want to provide a very simple easy way to upload files using native web browser controls. Anything else like loading indicators / swf uploader will add lots of extra complexity.
I havent tried uploading a big file yet, but i assume I could add a javascript action to the button that places an animated gif on the site.
Would there be any way to store files in sub directories based on user ID? I am thinking for community based sites where lots of members will be uploading content, giving each member their own sub directory would make things much neater.Hmm maybe… but probably not. At the moment the extension obeys the file upload prefs you set in the admin. Actually thinking on the fly maybe I could add this in as an option…That would work ok I guess. 😊lg_file_upload_sub_folder = '{member_id}'
I was assuming it would be something like you suggested, it’s still tied to the file upload prefs but can make subfolders in that directory only. If you could add this, i would find it very useful (hopefully other people would too).
Ok I finally think this one is sorted out…
Heres the hotfix. Change the form_declaration_method to:
/**
* Modify the $data parameters before they are processed by the user side form creator
*
* @param array $data The form data
* @return array The form data
* @since Version 1.0.0
* @see http://expressionengine.com/developers/extension_hooks/form_declaration_modify_data/
*/
function form_declaration_modify_data($data)
{
global $EXT, $TMPL;
// -- Check if we're not the only one using this hook
if($EXT->last_call !== FALSE) $data = $EXT->last_call;
// check if the $TMPL is an object
// on the traditional member pages this hook is called but there are no templates.
if(is_object($TMPL) === TRUE && $TMPL->fetch_param('lg_saef_file_upload') == 'y')
{
$data['enctype']='multi';
$data['hidden_fields']['lg_saef_file_upload'] = 'y';
$data['hidden_fields']['lg_saef_file_upload_dir_id'] = $TMPL->fetch_param('lg_saef_file_upload_dir_id');
}
return $data;
}
And see how you go
Leevi,
Finally gave your plugin a shot. Initially, I was having trouble uploading to a directory, but once I switched it to another one, I logged in through FTP and found the files there. 😊
Problem is, when I went to “Edit” and checked out the entries, the custom field I used for the file was not updated and was left blank.
I used this code for the SAEF, pretty much what you supplied in your initial post.
{exp:weblog:entry_form weblog="upload" lg_saef_file_upload="y" lg_saef_file_upload_dir_id="3"}
<input type="text" name="title" id="title" value="{title}" /></p>
<div>
<input type="file" name="field_id_12" value="" />
</div>
<input type='submit' value='submit' />
{/exp:weblog:entry_form}
If it’s any consolation, I’m running ExpressionEngine 1.6.4.. Fields are uploading, just the field isn’t populated when I hit “Edit”.
Just to be clear on how this works.. I created a custom weblog field and made the the field type “Text Input” and popped a 384 character limit on it. After it’s created, I check the field_id for the designated field and apply that to the “name” of the field in an SAEF? Also, just inacse you need to know, I just updated to the newest version of EE and am attempting this upload as a Super Admin.
Cheers, Danny
Hmmm not sure whats going on…
Heres my test template:
<h1>New Entry</h1>
{exp:weblog:entry_form
weblog = "upload_test"
lg_saef_file_upload = "y"
lg_saef_file_upload_dir_id = "1"
}
<label>Title: <input type="text" name="title" value="" /></label>
<label>File 1: <input type="file" name="field_id_224" value="" /></label>
<label>File 2: <input type="file" name="field_id_225" value="" /></label>
<input type='submit' value='Submit' />
{/exp:weblog:entry_form}
{exp:weblog:entries}
<h1>Edit Entry {entry_id}</h1>
{exp:weblog:entry_form
weblog = "upload_test"
lg_saef_file_upload = "y"
lg_saef_file_upload_dir_id = "1"
}
<input type="hidden" name="entry_id" value="{entry_id}" />
<input type="hidden" name="entry_date" value="{entry_date format='%Y-%m-%d %g:%i %A'}" />
<div><label>Title: <input type="text" name="title" value="{title}" /></label>
</div>
<div><label>File 1:
[img src='{upload_path_1}']
<input type="file" name="field_id_224" value="" /></label></div>
<div><label>File 2:
[img src='{upload_path_1}']
<input type="file" name="field_id_225" value="" /></label></div>
<input type='submit' value='Submit' />
{/exp:weblog:entry_form}
{/exp:weblog:entries}
Try give that a whirl and see if anything different happens…
upload_path_1 and upload_path_2 are my custom fields
Ok just picked it up… you need a entry_id and entry_date hidden input…
<input type="hidden" name="entry_id" value="{entry_id}" />
<input type="hidden" name="entry_date" value="{entry_date format='%Y-%m-%d %g:%i %A'}" />
That shoul sort out your edit from.
Over and out… I’m off to drink some beers 😊
Leevi,
Thanks for the quick reply!
I’ve used the majority of your code provided (with one upload field rather than 2) and it still doesn’t seem to be populating the Text Input field that the ID corresponds to. When I upload a file, is my understanding correct in that it would automatically populate the field with something like this, https://ellislab.com/asset/images/ent-partner-work/Image.jpg?
The images seem to upload fine, but they aren’t “sticking” to its respective field. Can’t really say what’s up, the usage is pretty self-explanatory, and the Change Logs in EE 1.6.4 doesn’t seem to far out there. Have you managed to get this working with 1.6.4?
UPDATE #1: Just saw your reply after I posted. I’ll take a look at that. By the way, when I mean “Edit”, I mean Edit as in the back-end administration panel rather than a Stand-Alone “Edit” Form. Will keep you posted.
UPDATE #2: Can’t seem to determine the cause. The files are certainly being uploaded to the specified directory without issues. Has anyone experienced issues with 1.6.4? I’m using the most generic SAEF as possible with the only custom field being dedicated to LG SAEF File Upload, but can’t seem to get the field to populate even though the file gets processed.
I’m having the same problem as Danny. The file uploads but the field doesn’t get populated.
Here’s the pertinent part of the code:
{exp:weblog:entry_form weblog="the-weblog" return="sundry/enter-post" lg_saef_file_upload = "y" lg_saef_file_upload_dir_id = "1"}
<input type="text" name="title" id="title" value="{title}">
<input type="hidden" name="entry_date" value="{entry_date}">
<input type="file" name="weblog-image" value="">
<input type="submit" name="submit" value="Submit">
{/exp:weblog:entry_form}
Also tried with a hidden entry_id field as suggested above; but I’m only working with an entry - not edit - form, so I’m not sure if I need it. In any event, its presence or absence didn’t make a difference.
I too am on 1.6.4. And, just so everything’s clear, the weblog/section I’m working with happens to be called the-weblog (it’s the blog on a site with many other sections) and the custom field ID actually is weblog-image.
Also, when I used the date format that was suggested earlier in the thread for the hidden date field, EE wouldn’t accept my entry, so I changed it to the default.
Thanks, Nathan
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.