Ok guys,
I know it has been attempted many times before (some attempts more successful than others) but I have developed my own SAEF file upload extension.
My extension is super easy to use… just install and add the following code to your SAEF form…
{exp:weblog:entry_form
weblog = "gallery"
lg_saef_file_upload = "y"
lg_saef_file_upload_dir_id = "1"
}
<input type="file" name="field_id_7" value="" />
<input type='submit' value='submit' />
{/exp:weblog:entry_form}
Simple….
Like I said this has been attempted many times before so I want to get it right…
UPDATE 1 June 23rd 4:49pm
I have tweaked a bit of the code and added the requested edit feature (needs some testing)
So now if you have an edit form you can add a new hidden field that stores the original value. If the file upload element is empty the original value will be used otherwise the extension will try and overide the previous file.
Example:
{exp:weblog:entry_form
weblog = "gallery"
lg_saef_file_upload = "y"
lg_saef_file_upload_dir_id = "1"
}
<input type="file" name="field_id_7" value="" />
<input type="hidden" name="field_id_7" value="{custom_field_that_holds_the_data}" />
<input type='submit' value='submit' />
{/exp:weblog:entry_form}
Note there is no way to delete a file yet.. Hopefully that will be coming soon.
If you are having issues with logging into the cp turn off auto update checking when you install the extension.
Grab the latest download.
UPDATE 2 June 23rd 5:30pm
Ok after a bit more testing I have realised there is no need for the hidden field… It actually causes complications…
Here is a basic edit form:
{exp:weblog:entries entry_id="{segment_1}"}
{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'}" />
<input type="text" name="title" value="{title}" />
<div>
<input type="file" name="field_id_224" value="" />
</div>
<div>
<input type="file" name="field_id_225" value="" />
</div>
<input type='submit' value='submit' />
{/exp:weblog:entry_form}
{/exp:weblog:entries}
You will obviously need to edit the field_ids and the weblogs entry loop… but I think we are getting there.
UPDATE 3 June 24th 8:08am
I have uploaded a new version which should crush the member login bug some user have been reporting..
Here is the first cut of LG SAEF Uploader.
To use all you need to do is add a couple of params to your opening form tag.
lg_saef_file_upload=”y” … Tells the extension to change the form encryption type lg_saef_file_upload_dir_id=” … The upload directory id set in the upload prefs
The set your input name to the id value of the field.
{exp:weblog:entry_form
weblog = "gallery"
lg_saef_file_upload = "y"
lg_saef_file_upload_dir_id = "1"
}
<input type="file" name="field_id_7" value="" />
<input type='submit' value='submit' />
{/exp:weblog:entry_form}
The extension is MSM aware, although there is nothing that requires this functionality yet.
There is no support for preview yet… and I’m not sure how to go about SAEF editing. I’ll have to look into it. Any suggestions are welcome.
Cheers Leevi
Please disreagrd this comment. It is no longer valid
So your trying to log into the admin?
Quick fix…
Try adding:
if ( ! defined('TMPL')) return $data;
around line 373 in the extension file.
The new function should look like:
<pre><code> /** * 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;
if ( ! defined('TMPL')) return $data;
if($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');
}
//$this->_debug($data, FALSE);
return $data;
}[/code]
So I installed the entension, and it was great, worked, until…I had the same issue above, so I modified the file as directed and that was cool, until…I logged out.
Then when I went to log back in to the CP all I had was a blank screen. Cleared everything and still blank. Went to another machine and got the login page. Logged in and, guess what? Blank screen again.
So I logged in to phpmyadmin and deleted the extension there and all is cool, but no upload :(.
Any ideas? It is a great idea, but not good if it crashes everything.
Initially the original file didn’t work. All off the links to member profiles returned errors. When I added the change that was fixed.
But I still get a blank page with either file, the original, or the edited one, after logging out. If the extension is disabled I have no issues. But that’s no good either!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.