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

I’m using Prototype too btw.



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

w00t! Got it working - thanks for your help! Now maybe I can launch my site 😉 Just hope that everything works when I move it over to the production server.

       
Qrat's avatar
Qrat
40 posts
17 years ago
Qrat's avatar Qrat

wondermonkey not all of your code shows.

{custom_field}

function  markForRemove(checkee) {
if (checkee.checked==true) {
$('thefile_link').style.textDecoration='line-through';
$('file_browser')[removed] = $('file_browse_fields')[removed];
} else {
$('thefile_link').style.textDecoration='underline';
$('file_browser')[removed] = '';
}
}

I see “[removed]” please can you attach your code to file?

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

Oh, interesting. I didn’t see that before. Those [removed] markers should be replaced with ‘[removed]’

       
simplyee's avatar
simplyee
104 posts
17 years ago
simplyee's avatar simplyee

Been following this, and the original thread. While I read most of the original, I feel certain this thread is where it’s at.

My SAEF works, but only with one file, not multiple ones. Have you all tried, and succeeded in getting the multiple file function working?

In my CP the multiple files work, but in the SAEF not.

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

simply ee: I haven’t tried it yet, but I’m quite certain it’s just a matter of copy/pasting the input code directly from your CP’s html. If not then you got me!

       
simplyee's avatar
simplyee
104 posts
17 years ago
simplyee's avatar simplyee

I’m sure you’re right, just haven’t looked, but will try it. Just don’t want to beat a dead horse. Seems like there have been quite a few issues using this.

       
shinka's avatar
shinka
138 posts
17 years ago
shinka's avatar shinka

Hmm… I’m not being able to get it to work. Any ideas? I’m getting a MySQL error:

MySQL ERROR: Error Number: 1054 Description: Unknown column ‘field_id_15_img’ in ‘field list’ Query: INSERT INTO `exp_weblog_data` (`entry_id`, `weblog_id`, `field_id_15_img`, `field_id_15`, `field_ft_15`, `field_id_15_img_0`, `site_id`) VALUES (‘20’, ‘7’, ‘Array’, ”, ‘file’, ‘liedcenter_2.jpg’, ‘1’)

<pre><code>{exp:weblog:entry_form weblog="photos" return="photos/thank_you"} <label for=”title”>Title</label>

            <input type="text" id="title" value="{title}" name="title" /></p>

            <label for="photo_description">Description</label>


            <textarea rows="8" cols="35" id="photo_description" name="photo_description"></textarea>
            <label for="photo_file">File Upload:</label>


            <input class="labelfirst" name="field_id_15_img[]" id="file_browser" type="file" value="" />

<input type=”hidden” value=”” class=”file” name=”field_id_15”/> <input type=”hidden” value=”file” class=”file” name=”field_ft_15”/>

            <input type="submit" name="submit" value="Upload and Submit Photo" />
            {/exp:weblog:entry_form}[/code]
       
shinka's avatar
shinka
138 posts
17 years ago
shinka's avatar shinka

Just tried again. Reinstalled the file, added a new field. Now I’m getting this error:

Fatal error: Call to a member function show_user_error() on a non-object in …/extensions/ext.mh_file_ext.php on line 857

Looks like something similar was reported here but never was addressed: http://ellislab.com/forums/viewreply/357945/ Thanks.

Nevermind…just reinstalled the file again and now it’s working!

       
MaxDulux's avatar
MaxDulux
22 posts
about 17 years ago
MaxDulux's avatar MaxDulux

Trying to build an SAEF to up load one image and one mp3 file. Works fine from the CP. Will not upload mp3 files from the front end. Is there ANYBODY with a solution to this. I have adjusted the PHP.ini file and upped the file upload and time limits so I am sure it isn’t that. Especially as it all seemd to work in the CP. My SAEF code is below…

{exp:weblog:entry_form weblog="mynss" return="site/index" preview="site/entry"}

{preview}
<h1>{title}</h1>

{display_custom_fields}

{/preview}





           <label for="bandName">BAND NAME: <span class="feedback">Required</span></label>
           <input type="text" name="title" id="title" value="{title}" />



{custom_fields}
<!--{if required}* {/if}{field_label}

{field_instructions}--> 


{if textarea}
<label for="textarea" >{field_label}: <span class="feedback">{field_instructions}</span></label>
<textarea id="{field_name}" name="{field_name}" dir="{text_direction}"  rows="{rows}">{field_data}</textarea><br >
{/if}






{if textinput}
<label for="text" >{field_label}: <span class="feedback">{field_instructions}</span></label>
<input type="text" dir="{text_direction}" id="{field_name}" name="{field_name}" value="{field_data}" maxlength="{maxlength}" ></p>

{/if}

{if pulldown}
<label for="pulldown">{field_label}: </label>
 <select id="{field_name}" name="{field_name}">
{options}<option value="{option_value}"{selected}>{option_name}</option>{/options}
</select>

{/if}

{if date}
<input type="text" id="{field_name}" name="{field_name}" value="{field_data}" maxlength="{maxlength}" size="50">
{/if}

{if relationship}
<select id="{field_name}" name="{field_name}">
{options}<option value="{option_value}"{selected}>{option_name}</option>{/options}
</select>
{/if}
{/custom_fields} 


          
            <label for="filepc">UPLOAD A PHOTO: <span class="feedback">{field_instructions}</span></label>
<input type="hidden" name="field_id_47" value="" />
<input name="field_id_47_img[]" type="file" class="file" /></p>

      
            <label for="filepc">UPLOAD AN MP3: <span class="feedback">{field_instructions}</span></label>
<input type="hidden" name="field_id_48" value="" />
<input name="field_id_48" type="file" class="file" /></p>


<label>SHARE YOUR NSS:<span class="feedback">Refer to the FAQ section for instructions on how to incorporate these social networking sites onto your NSS page.</span></label>





          <br class="clear" >    <br class="clear" >    <br class="clear" >
        <div id="terms"><div class="group3">  
            <input type="checkbox" name="agreement" id="agreement" class="checkbox"/>
            I have read and understood the NSS website terms and conditions of use. I agree to abide by the rules set out in the terms and conditions.
          
           <br class="clear" >
           
           
           
            <input name="clear" type="reset" class="button" id="clear" value="Clear" />
            <input name="Login" type="submit" class="button" id="Login" value="Submit" />
           


{/exp:weblog:entry_form}

Thanks for any input to help solve this. It is critical that this site have this feature.

       
MaxDulux's avatar
MaxDulux
22 posts
about 17 years ago
MaxDulux's avatar MaxDulux

Whoops! got it now. I was missing the img[] from the input name – field_id_48_img[] – I thought that it wasn’t needed because I use that field for mp3 and not images.

Now if I can just get it to upload in the background so that the user isn’t left with the form in front of then waiting for the file to upload and wondering what is happening or not then I will truly be a happy camper.

Next I want to attempt to allow members to edit their entry…..

       
Gert Timmerman's avatar
Gert Timmerman
33 posts
16 years ago
Gert Timmerman's avatar Gert Timmerman

the upload works, but i have a question about deleting the image or file: will the file also be deleted at the server? i’ve got the deleting part working, but the file is not deleted from the server ..

       
Nathan Pitman's avatar
Nathan Pitman
531 posts
16 years ago
Nathan Pitman's avatar Nathan Pitman

This is absolute genius. I was playing with Leevi Grahams LG SAEF File Upload Extension but it didn’t seem to play nice with Mark Huot’s File Extension in the CP.

At present I don’t have this implemented on an ‘edit’ form. Does it allow the user to remove and/or replace files in the same way as it does via the CP??? I’m assuming so?

       
Nathan Pitman's avatar
Nathan Pitman
531 posts
16 years ago
Nathan Pitman's avatar Nathan Pitman

Ok so I tried to add the code outlined here to an edit form but if I submit the form without selecting a file to upload then the original file reference in the custom field is cleared. If I submit a new file it uploads fine but does not ‘replace’ the original for this weblog entry…

1: Is there some way to make this play nice with an edit form?

2: Is there some way to have the file be renamed to the same name as the ‘previous’ file that was uploaded at the ‘add’ stage?

Any pointers greatly appreciated! 😊

       
Nathan Pitman's avatar
Nathan Pitman
531 posts
16 years ago
Nathan Pitman's avatar Nathan Pitman

Ok, a solution to problem #2:

In the File Extension change line 767 to read:

$file_names[$file_key] = $_POST['entry_id']."_field_id_".$file_field['field_id'].$file['ext'];

This will name your file uploads after both the entry id and also the field id which they are associated with. So long as you ensure that you enable ‘rewrite filenames’ in the file upload prefs for this extension that this works from both the CP and a SAEF (Stand Alone Edit Form). Now all I need to do is resolve problem #1 and I’m sorted… though of course there’s always that mystical solution that will have the extension delete associated files from the upload folder when you delete the related entry from the CP. 😊

UPDATE Actually this doesn’t work. In the end I’ve gone with using the url_title as a unique since the entry_id does not exist on a POST from the initial ‘add’ form. After a bit of hacking about with the File Extension I seem to have a solution up and running where I can add edit and delete files all from a SAEF. Phew!

😊

       
1 2 3 4 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.