Hello. I just wanted to add here that I have also had the same error message on Form Submission:
Fatal error: Call to a member function show_user_error() on a non-object in /client/site/my_public/system/extensions/ext.mh_file_ext.php on line 857
I am using the current versions of EE, the latest File extension and a SAEF which does Submit & Preview.
What would be useful is if someone has a SAEF with this extension for multiple image uploads, AND, the form has the capacity to be recalled by an author from the database for further editing… so status might include DRAFT.
Thank you in advance for any help here (from a relative new EE admirer).
Hello Again.
I believe I just cured the previous problem… (well it is currently working and sending all Form content through to the database, and being published as expected).
I was looking at Forum Threads and noticed that there was a difference in these two file upload scripts:
Thread: http://ellislab.com/forums/viewthread/75387/
SCRIPT 1
<input class=”required” id=”file_content” title=”Please upload a file. This field is required.” name=”field_id_21_img[]” type=”file” />
<input type=”hidden” value=”” class=”file” name=”field_id_21”/> <input type=”hidden” value=”file” class=”file” name=”field_ft_21”/>
AND
SCRIPT 2
<input class=”required” id=”file_content” title=”Please upload a file. This field is required.” name=”field_id_21_img[]” type=”file” />
<input type=”hidden” value=”” class=”file” name=”field_id_21”/> <input type=”hidden” class=”file” name=”field_ft_21”/>
NOTE. In the second script, there is no reference to value=”file” in the second hidden field.
I was having the problem: Fatal error: Call to a member function show_user_error() on a non-object in /client/site/my_public/system/extensions/ext.mh_file_ext.php on line 857
when I included the value=”file” in the second hidden field.
So i removed it, and Hey Presto, the form uploaded as it should.
HOWEVER, this value=”file” can also be changed to value=”field_ft_21” or whatever your field_ft_XX is as this also worked for me. This Value information would be critical for when a form is recalled by a user for updating and amending etc.
I am still testing here so if anything changes I will add to this post.
Cheers.
Help! I’ve got the File extension working just fine within an SAEF.. everything uploading great. I’d love for the logged in user to then be able to delete / edit photos that have been uploaded (but not within the control panel). Can anyone share how this might be done? Are there other extensions or plugins that would make this possible? Any help appreciated.
sherrills- here is the code from my edit page, allowing users to add or delete images…
{image} is my custom field which I get the {file_url} and {file_name} from, I figure if you’ve already got the SAEF working you’ll know the rest of what’s going on in here, I get the entry id initially from a segment in the URL… I figure it’s the checkbox “field_id_17_remove[]” that’s at the heart of it all…
[removed]
(that's an opening script tag, the forum automatically removes it from posts)
function addRow( self )
{
if(typeof(self) != "object") self = this;
if(!self.nodeName || self.nodeName != "INPUT") self = this;
var tr = document.createElement("tr");
var td = document.createElement("td");
td.className = "tableCellTwo";
td.colSpan = 2;
tr.appendChild(td);
var input = document.createElement("input");
if(self.onchange) input.onchange = addRow;
input.type = "file";
input.name = self.name;
td.appendChild(input);
self[removed][removed][removed].appendChild(tr);
return false;
}
function markForRemove( self )
{
if(typeof(self) != "object") self = this;
if(!self.nodeName || self.nodeName != "INPUT") self = this;
if(self.checked == true)
{
self[removed][removed].className = "deleted";
}
else
{
self[removed][removed].className = "";
}
var file_input = false;
var checkboxes = 0;
var inputs = self[removed][removed][removed].getElementsByTagName("input");
for(var i=0; i<inputs.length; i++)
{
if(inputs[i].type == "checkbox")
{
checkboxes++;
}
else if(inputs[i].type == "file")
{
file_input = inputs[i];
}
}
if(checkboxes == 1 && file_input != false)
{
if(file_input[removed][removed].style.display == "none")
{
file_input.quick_show = true;
if(document.all) file_input[removed][removed].style.display = "block";
else file_input[removed][removed].style.display = "table-row";
}
else if(file_input[removed][removed].style.display != "none" && file_input.quick_show == true)
{
if(document.all) file_input[removed][removed].style.display = "none";
else file_input[removed][removed].style.display = "none";
}
}
}
var loader = document.createElement("img");
loader.src = "/images/icons/upload.gif";
loader.alt = "Uploading...";
function uploadFiles()
{
var inputs = document.forms[0].getElementsByTagName("input");
for(var index=0; len=inputs.length,index<len; ++index)
{
var input = inputs[index];
if(input.getAttribute("type").toLowerCase() != "file") continue;
if(input.value == "") continue;
input[removed].appendChild(loader.cloneNode());
input.style.position = "absolute";
input.style.left = "-9999px";
}
return true;
}
[removed]
(that was the end of the script tag)
{exp:weblog:entries weblog="[weblog]" entry_id="[entry ID]"}
{exp:weblog:entry_form weblog="[weblog]" return="[return page]"}
<input type="hidden" name="entry_id" value="{entry_id}" />
<input type="hidden" name="field_ft_17" value="xhtml" />
<strong>Images(s)</strong>
{image}
{file_url}
<input type="checkbox" name="field_id_17_remove[]" value="{file_name}" class="delete" id="delete_checkbox" /> <span>check to delete</span>
{/image}
<span class="fileUpload">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<input name="field_id_17_img[]" type="file" class="file" >
<input type="hidden" value="" class="file" name="field_ft_17" />
<input type="hidden" name="field_id_17" value="" />
</td>
</tr>
</table>
</span>
<input type="submit" name="submit" value="Submit" class="sendBtn" />
{/exp:weblog:entry_form}
{/exp:weblog:entries}
@adlur
Man, you have no idea how much I appreciate you putting this up! I’ve literally been losing sleep over this one. I’ve got it working perfectly for uploading a single image / deleting that same single image. I’m trying to set it up so that I can upload multiple images but can’t seem to get that bit working. Any chance that you (or anyone else) can take a look at my code and tell me what I’d need to do ?
{exp:weblog:entries weblog="default_site" entry_id="81"}
{exp:weblog:entry_form weblog="default_site" return="/test5"}
<input type="hidden" id="title" class="input" name="title" value="{title}" size="40" maxlength="100">
<input type="hidden" id="url_title" name="url_title" value="{url_title}" size="40" maxlength="100" />
<input type="hidden" name="entry_id" value="{entry_id}" />
<input type="hidden" name="field_ft_9" value="xhtml" />
<strong>Images(s)</strong>
{file1}
{file_url}
<input type="checkbox" name="field_id_9_remove[]" value="{file_name}" class="delete" id="delete_checkbox" /> <span>check to delete</span>
{/file1}
<span class="fileUpload">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<input name="field_id_9_img[]" type="file" class="file" >
<input type="hidden" value="" class="file" name="field_ft_9" />
<input type="hidden" name="field_id_9" value="" />
</td>
</tr>
</table>
</span>
<input type="submit" name="submit" value="Submit" class="sendBtn" />
{/exp:weblog:entry_form}
{/exp:weblog:entries}
Adlur, yes - the javascript is loading just fine in the edit page - i’m able to delete an image.. and upload a replacement image no problem. The only thing I was trying to figure out was how to go about uploading multiple images - wasn’t sure what that code would look like or if that’s something you did with your project. Any advice on that would be a huge help. But the overall functionality is perfect so again many thanks for sharing!
sherrills, wouldn’t you know it- testing my edit form to see why yours might not be working pointed me to a flaw- I had to change the hidden file name field….
Applied to your code:
{exp:weblog:entries weblog="default_site" entry_id="81"}
{exp:weblog:entry_form weblog="default_site" return="/test5"}
<input type="hidden" id="title" class="input" name="title" value="{title}" size="40" maxlength="100">
<input type="hidden" id="url_title" name="url_title" value="{url_title}" size="40" maxlength="100" />
<input type="hidden" name="entry_id" value="{entry_id}" />
<input type="hidden" name="field_ft_9" value="xhtml" />
// BOF new!
<input type="hidden" name="field_id_9" value="{file1}{file_name}
{/file1}" />
//EOF new!
<strong>Images(s)</strong>
{file1}
{file_url}
<input type="checkbox" name="field_id_9_remove[]" value="{file_name}" class="delete" id="delete_checkbox" /> <span>check to delete</span>
{/file1}
<span class="fileUpload">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
//add onChange="return addRow(this);" to this input, it's what calls the JS function addRow() to create a new input, which might of been your issue from the start- the forum won't let me put it in this code, not sure why
<input name="field_id_9_img[]" type="file" class="file" />
//BOF remove!
<!--
<input type="hidden" value="" class="file" name="field_ft_9" />
<input type="hidden" name="field_id_9" value="" />
-->
//EOF remove!
</td>
</tr>
</table>
</span>
<input type="submit" name="submit" value="Submit" class="sendBtn" />
{/exp:weblog:entry_form}
{/exp:weblog:entries}
note that the hidden file name field is removed from the {file1} loop that displays the image and the remove checkbox- it needs to create an array of file names for the extension- also very important to this is the line break- the extension is looking for “\r” and uses it to explode the results and create an array… As far as I can tell my form is now working in any scenario, I’ve tested editing the entry without touching any images, editing the entry by deleting a single image, editing the entry by adding one (or more) images and editing the form by removing one (or more) images and adding one (or more) images at the same time.
I also removed the second hidden input value for “field_ft_9”, I had the same thing in mine but I realize it’s a repeat, the value is set to “xhtml” at the start of your form- to be honest I’m not sure if it’s necessary at all, I read somewhere that if you don’t include the field format setting things would start to get messed up… Although in this case maybe it should be “file” rather than “xhtml”?
Last little detail, is “Allow Multiple Uploads?” set to “yes” in your file upload preferences for the directory that the custom field {file1} uploads into?
Hope it works out!
I too am running into the call to member fatal error. It seems to work maybe 1 out of 10 times (if I’m lucky) when uploading multiple images. Otherwise I get:
Fatal error: Call to a member function show_user_error() on a non-object in /path/extensions/ext.mh_file_ext.php on line 857
journalistone, I think you have the fix in your above post but I couldn’t follow exactly what it is that you ended up with. Anyone else that has encountered and fixed this, I’d love to see your exact code or get clear instructions on what you did to fix it!!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.