1 of 2
1
Hardcoded SAEF File Upload in EE2
Posted: 05 April 2010 12:13 PM   [ Ignore ]  
Summer Student
Total Posts:  4
Joined  04-05-2010

Can someone tell me the proper way to hardcode a file upload field in a standalone entry form in EE2?

If I just use this:

<input type="file" name="field_id_8" id="field_id_8" value="" /> 

I can select a file for upload, but it doesn’t get saved.

Thanks so much for the help. It would really really help me to figure this out ASAP.

[Mod Edit: Moved to the How to forum]

Profile
 
 
Posted: 05 April 2010 02:43 PM   [ Ignore ]   [ # 1 ]  
Chancellor's Fellow
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  33338
Joined  05-15-2004

Welcome to the forums, js1999. Please take a look at the example in the docs, which shows the supported way.

Have you tried to take a look at the rendered output of such code, and take it from there?

Profile
MSG
 
 
Posted: 05 April 2010 03:09 PM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  4
Joined  04-05-2010

Hi,

I have tried this and still can’t figure it out. Also, I really don’t want the user to be able to see all the other uploaded files.

Can you give any more specific help?

Thanks.

Profile
 
 
Posted: 05 April 2010 03:12 PM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  730
Joined  11-11-2006

Did you know that file upload in EE2 via SAEF is broken and has been for quite a while: http://expressionengine.com/bug_tracker/bug/11244/

Profile
 
 
Posted: 05 April 2010 03:14 PM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  4
Joined  04-05-2010

I did not know that. Thank you. Seems like it should be top of their list to fix!

Are there any other ways to accept user uploads in EE2?

Thanks!

Profile
 
 
Posted: 05 April 2010 03:31 PM   [ Ignore ]   [ # 5 ]  
Chancellor's Fellow
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  33338
Joined  05-15-2004

Thanks for reminding us of that one, leeaston Lee. Had slipped my mind, actually smile

Profile
MSG
 
 
Posted: 05 April 2010 03:33 PM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  730
Joined  11-11-2006

Call me Lee.

Profile
 
 
Posted: 05 April 2010 03:35 PM   [ Ignore ]   [ # 7 ]  
Chancellor's Fellow
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  33338
Joined  05-15-2004

I can do that smile Does that explain the issue to you, js1999? Keep an eye out for a new build that fixes this.

Profile
MSG
 
 
Posted: 05 April 2010 09:38 PM   [ Ignore ]   [ # 8 ]  
Summer Student
Total Posts:  4
Joined  04-05-2010

It (sort of) answers my question, but it doesn’t solve my problem.

Are there any other ways to accept user uploads in EE2?

If not, is there anyone who has any idea when this issue will be fixed?

Profile
 
 
Posted: 05 April 2010 10:16 PM   [ Ignore ]   [ # 9 ]  
Chancellor's Fellow
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  30388
Joined  04-29-2002

Unfortunately we don’t have an ETA for a fix quite yet. There isn’t a known workaround. Content managers can always be given access to the back end and be prevented from seeing parts of the site you want to hide.

Profile
MSG
 
 
Posted: 28 June 2010 05:36 AM   [ Ignore ]   [ # 10 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  446
Joined  01-14-2006

I just wanted a simple file field, no filemanager so I started poking around, and I *think* I’ve found a workaround… but it does have a downside.

In my saef, I’m using the following code to output the file upload field:

<input type="file" name="field_id_2" value="{field_id_2}" id="upload_file" size="20" class="field" />
<
input type="text" name="field_id_2_directory" value="1" /> 

“field_id_x” should be modified to match your file field ID, and the “field_id_x_directory” value should be updated to match your upload directory ID.

Downside is via the cp, EE will prepend the filename with the filedir shortname, eg { filedir_1 }myimage.jpg - but if you upload via the saef, you only get the filename stored in the db. this means while editing the entry via the cp, you get squat in your field, it appears to be empty - even though you have uploaded the file, and the filename is stored in the field.

I tried changing the field type to just a text input, and then upload a file but then EE falls over and displays an error when trying to upload the file via the saef:

Error Number1054

Unknown column 
'field_id_2_directory' in 'field list'

UPDATE exp_channel_data SET channel_id '1'field_id_2_directory '1' WHERE `entry_id` = '9' 

I should be able to create a file field from here, but doubt I will be able to share the code as I’ll need to blag Ellislab code to get it working.

Hopefully this might help some others get going though.

Edit: {filedir_x} renders on this forum?

http://ellislab.com/images/uploads/

Iain,

 Signature 

Weblog | @iain | Taxonomy for EE2

Profile
 
 
Posted: 28 June 2010 03:26 PM   [ Ignore ]   [ # 11 ]  
Chancellor's Fellow
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  33338
Joined  05-15-2004

Thanks for your feedback, Iain.

Profile
MSG
 
 
Posted: 03 July 2010 02:37 PM   [ Ignore ]   [ # 12 ]  
Summer Student
Total Posts:  20
Joined  08-19-2008

Iain - thanks for posting that - I’m trying to do something similar and that was really helpful.

I’m probably going to use a custom ajax interface to handle the actual upload and then pump the filename into the hidden field as follows

<input type="hidden" name="field_id_4_hidden" value="{filedir_1}my_file_name_inserted_using_jquery.jpg" /> 


I’m not keen on being reliant on javascript to achieve this, though, so wondered if you were trying something snazzy with an extension hook?


Cheers,
Tim

Profile
 
 
Posted: 03 July 2010 03:26 PM   [ Ignore ]   [ # 13 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  5126
Joined  06-20-2005

Hi js1999,

I’m going to close out this thread as a technical support issue but if you’d rather continue the conversation about other ways to upload files then I can move this into the How To forum if you’d prefer?

Cheers

Greg

 Signature 

   Purple Dogfish | Member of EE Pro Network | Follow me on Twitter

Profile
MSG
 
 
Posted: 04 July 2010 12:33 AM   [ Ignore ]   [ # 14 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  446
Joined  01-14-2006

@Greg, yep, please move to How to, thank you.

@Tim, just started writing an extension now, the ‘entry_submission_redirect’ hook should work,

The data returned by the hook doesn’t include any data from the custom fields, but it does return the ‘field_id_x_directory’ data (see below) which will allow me to detect which fields need updated.

Array
(
    
[ping_errors] => 
    
[revision_post] => Array
        (
            
[ACT] => 5
            [RET] 
=> http://sitename:8888/index.php/members
            
[PRV] => site/entry
            [URI] 
=> members
            [XID] 
=> b1f0ccb0eee12b7fc808e4f42ff1f3513f60bd7c
            [author_id] 
=> 1
            [channel_id] 
=> 1
            [site_id] 
=> 1
            [entry_id] 
=> 1
            [url_title] 
=> my_first_entry
            [title] 
=> My first Entry
            [field_id_1_directory] 
=> 1
            [submit] 
=> Submit
            [entry_date] 
=> 1277664048
        
)

    
[ACT] => 5
    [RET] 
=> http://sitename:8888/index.php/members
    
[PRV] => site/entry
    [URI] 
=> members
    [XID] 
=> b1f0ccb0eee12b7fc808e4f42ff1f3513f60bd7c
    [channel_id] 
=> 1
    [site_id] 
=> 1
    [entry_id] 
=> 1
    [submit] 
=> Submit
    [ping_servers] 
=> Array
        (
        )

This all seems a little hacky to me though, I wish EllisLab would introduce a way of uploading files without exposing the file manager,

I’ll let you know how I go.

 Signature 

Weblog | @iain | Taxonomy for EE2

Profile
 
 
Posted: 04 July 2010 05:14 AM   [ Ignore ]   [ # 15 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  446
Joined  01-14-2006

Ok, my first ever extension, seems to work ok for me.

Do let me know how you get on, http://github.com/iainurquhart/Simple-SAEF-File-Uploads

Cheers

 Signature 

Weblog | @iain | Taxonomy for EE2

Profile
 
 
Posted: 04 July 2010 07:08 AM   [ Ignore ]   [ # 16 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  730
Joined  11-11-2006

Thanks - I can see this being very popular.

Profile
 
 
Posted: 04 July 2010 12:06 PM   [ Ignore ]   [ # 17 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  730
Joined  11-11-2006

I’m geting nothing saved into the custom field, just like like do when I use the standard way of uploading and which was reported here. Any suggestions?

Profile
 
 
Posted: 04 July 2010 04:53 PM   [ Ignore ]   [ # 18 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  446
Joined  01-14-2006

Maybe if you post some template code.

Triple check your file ids, and the file upload id.

If not, can you dm me details to access your cp?

 Signature 

Weblog | @iain | Taxonomy for EE2

Profile
 
 
   
1 of 2
1