We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

How to get Mark Huot’s File Extension to work with SAEF/Stand Alone Entry Form

Development and Programming

Ty Martin's avatar
Ty Martin
232 posts
17 years ago
Ty Martin's avatar Ty Martin

Here goes…

This is for the entry form. I can do an Edit form too if there’s big demand.

  1. Install Extension.

  2. Set up your file upload locations/preferences as required.

  3. Create a new custom field, field type: File, and set your upload location.

  4. Get the field_id number for your custom field.

  5. Build your SAEF as normal.

  6. Paste in something like:

<label for="content">File Upload:</label>


<input class="required" id="file_content" title="Please upload a file. This field is required." name="field_id_9_img[]" type="file" class='file' />


<input type="hidden" value="" class="file" name="field_id_9"/>
<input type="hidden" value="file" class="file" name="field_ft_9"/>
  1. Replace the ‘9’ in my code above with the field_id number from step 4.

  2. Test

       
Ryan M.'s avatar
Ryan M.
1,511 posts
17 years ago
Ryan M.'s avatar Ryan M.

Thanks for starting this thread, wondermonkey. I feel like I’m getting close. My little front-end file upload SAEF is doing everything but uploading the file. I was a little curious about the second line you posted here (112 is my field_id):

<input type="hidden" value="" class="file" name="field_id_112"/>
<input type="hidden" value="file" class="file" name="field_ft_112"/>

Is that really supposed to be “ft” on the second line? These fields look almost identical but one has a value of ‘file’ and the other has an empty value - and, of course one has ‘id’ and one has ‘ft’.

Also, is the ID on the input field supposed to match the short name of the field, or doesn’t that matter? I’m going to go back into the main thread to see if I’ve missed anything.

       
Ryan M.'s avatar
Ryan M.
1,511 posts
17 years ago
Ryan M.'s avatar Ryan M.

OK, I got this working with only a few extra things to do in addition to what you posted. Building on and updating your instructions:

  1. Install Mark Huot’s File Extension.

  2. Set up your file upload locations/preferences as required.

  3. Create a new custom field, field type: File, and set your upload location.

  4. Get the field_id number for your custom field. (in my example here, 112)

  5. Build your SAEF as normal.

  6. Paste in something like (at the most minimal):

<input type="hidden" name="field_id_112" value="" />
<input name="field_id_112_img[]" type="file" class="file" />
  1. We need the SAEF to have an enctype of “multipart/form-data”, which it does not by default. So download and install Jermaine M’s SAEF Enctype Extension from this post in the original “File” thread.

  2. Modify SAEF Enctype extension for your needs. It wouldn’t work out of the box for me because my SAEF has a dynamic and always different “URI” so I changed the options to look for the weblog id of the weblog where I’m storing files. This is the line you’ll need to modify in one way or another (appx line 96):

ORIGINAL CODE(looking at the URI hidden field)

if (isset($options['hidden_fields']['URI']) && $options['hidden_fields']['URI']=='/post/images/')
   $options['enctype']='multi';

MY MOD (changing which hidden field to look at)

if (isset($options['hidden_fields']['weblog_id']) && $options['hidden_fields']['weblog_id']=='19')
   $options['enctype']='multi';
  1. Test

  2. Jump for joy and think about how we may not have to do any of this stuff when 2.0 comes out.

Thanks to wondermonkey for starting this thread - which is certainly easier to search and read than the original thread.

       
Ty Martin's avatar
Ty Martin
232 posts
17 years ago
Ty Martin's avatar Ty Martin

Hey Masuga, Can I just say that your #7 & 8 are really confusing, but you did remind me of a key mod that I did to get this to work. My apologies for not posting it.

This would be step 7.5 (between 7 and 8):

In mod.weblog_standalone.php, find the following lines around 1444:

$data = array(
'hidden_fields' => $hidden_fields,
'action'        => $RET,
'id'            => 'entryform'
);

and insert this line (plus a comma after the last field)

'enctype' => 'multipart/form-data'

it will therefore be:

$data = array(
'hidden_fields' => $hidden_fields,
'action'        => $RET,
'id'            => 'entryform',
'enctype' => 'multipart/form-data'
);

From this post

       
Ty Martin's avatar
Ty Martin
232 posts
17 years ago
Ty Martin's avatar Ty Martin
Is that really supposed to be “ft” on the second line? These fields look almost identical but one has a value of ‘file’ and the other has an empty value - and, of course one has ‘id’ and one has ‘ft’.

Yes, if you look at the DB, you’ll see a field for field_ft_xx which stores the format of the field.

Also, is the ID on the input field supposed to match the short name of the field, or doesn’t that matter? I’m going to go back into the main thread to see if I’ve missed anything.

No, I do that so it makes sense to people reading it and to manipulate it with javascript (good practice).

       
Ryan M.'s avatar
Ryan M.
1,511 posts
17 years ago
Ryan M.'s avatar Ryan M.

7 is a way to get the form to use “multipart/form-data” without having to modify a core file - use the extension instead and you don’t mess with your core “mod.weblog_standalone.php” file.

       
Ty Martin's avatar
Ty Martin
232 posts
17 years ago
Ty Martin's avatar Ty Martin

Ah, yes, I see, but having to modify that extension is almost as bad.

Actually no, you’re right. Go with the modded extension.

       
Ryan M.'s avatar
Ryan M.
1,511 posts
17 years ago
Ryan M.'s avatar Ryan M.

Actually the extension isn’t bad at all. If you have the same return parameter every time, you just change one small thing. For me, my SAEF is embedded on a single-entry page - and I have many entries, so the return is different every time. However, in my case, I’m only uploading to weblog_19 from a SAEF, so I told the extension to look for that hidden parameter.

       
Dave Rau's avatar
Dave Rau
85 posts
17 years ago
Dave Rau's avatar Dave Rau

I’m very confused. I have what appears to be the correct code but my field is blank on upload and the file isn’t in my upload folder that I’ve associated the field with. Any ideas? I get no error messages, so I’m not sure where to start.

       
Ty Martin's avatar
Ty Martin
232 posts
17 years ago
Ty Martin's avatar Ty Martin

Is it working from the Control Panel? If not then you should head back to the original thread to start troubleshooting. That sounds like a problem with the ability to upload files, not with the SAEF. Also ensure that your SAEF works without uploading any files first.

Turn on error messages.

       
Dave Rau's avatar
Dave Rau
85 posts
17 years ago
Dave Rau's avatar Dave Rau

Uploads work fine thru the CP (just verified) and the SAEF will add the post topic, but not upload my file or add any filename reference to the field (it’s blank every time).

What else should I be checking? Thanks for the help so far.

       
Ty Martin's avatar
Ty Martin
232 posts
17 years ago
Ty Martin's avatar Ty Martin

Did you address the enctype issue discussed above (two possible solutions)?

       
Dave Rau's avatar
Dave Rau
85 posts
17 years ago
Dave Rau's avatar Dave Rau

yeah:

<form id='entryform' method="post" action="http://redlabor.com/ee/index.php/redlabor/remix_upload/"  enctype="multipart/form-data" >

I don’t think I have any template files named “remix_upload”. I’m feeling a little lost with EE paths still.

       
Ty Martin's avatar
Ty Martin
232 posts
17 years ago
Ty Martin's avatar Ty Martin

That sounds like it’s beyond a problem with the File extension and SAEF, or if not then it’s very likely you’re missing something basic. What version of EE are you using? I haven’t tested any of this on EE1.6.3 yet, only 1.6.2.

Keep playing with it though. When you take out the file upload form entirely from your SAEF does it work? Are your inputs named appropriately (very important)?

       
Jermaine M's avatar
Jermaine M
20 posts
17 years ago
Jermaine M's avatar Jermaine M

Wondermonkey, can you post info on the edit form? Finally tried to implement it and running into a minor issue where files marked for removal do not get deleted from the entry.

       
1 2 3 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.