Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

'HTTP Error' Uploading Documents using FileDataObjectManager


Go to End


46 Posts   12498 Views

Avatar
ajxtee

Community Member, 8 Posts

23 October 2010 at 1:48am

Hi,

I'm loving the new uploadify module but I'm having a problem uploading documents via the FileDataObject manager (specifically PDFs and Doc files). Images (JPEGs) work absolutely fine however. If I try to select a document the progress bar jumps immediately to 100% and reports 'HTTP Error.'

Any help would be much appreciated! Below is the code in question:

<document.php>

class Document extends DataObject {
static $db = array (
'Name' => 'Text',
'Description' => 'Text',
'Category'=> "Enum('Letters, Curriculum Maps, General')"
);

static $has_one = array (
'Attachment' => 'File',
'DocumentsPage' => 'DocumentsPage'
);

public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Name'),
new TextField('Description'),
new DropdownField('Category','Category', singleton('Document')->dbObject('Category')->enumValues()),
new FileIFrameField('Attachment')
);
}
}

<documentspage.php>

class DocumentsPage extends Page {
static $has_many = array (
'Documents' => 'Document'
);

static $allowed_children = array('Document');
static $default_child = 'Document';

public function getCMSFields()
{
$fields = parent::getCMSFields();
$manager = new FileDataObjectManager(
$this,
'Documents',
'Document',
'Attachment',
array(
'Name' => 'Name',
'Description' => 'Description',
'Category' => 'Category'
),
'getCMSFields_forPopup'
);
$fields->addFieldToTab("Root.Content.Documents",$manager);
return $fields;
}
}

Avatar
UncleCheese

Forum Moderator, 4102 Posts

23 October 2010 at 2:09am

You can add UploadifyField::show_debug(); to your _config.php and that should alert out the server response for you. Probably a parse error somewhere.

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
ajxtee

Community Member, 8 Posts

23 October 2010 at 2:25am

Thanks UncleCheese,

I've enabled that but not quite sure what I'm looking for in the output. The debug dialogue returned:

<<<<!DOCTYPE html><html><head><title>POST /lapford/admin/EditForm/field/Documents/UploadifyForm/field/UploadedFiles/upload?ctf[Documents][start]=0&amp;ctf[Documents][per_page]=10&amp;ctf[Documents][showall]=0&amp;ctf[Documents][sort]=&amp;ctf[Documents][sort_dir]=&amp;ctf[Documents][search]=&amp;ctf[Documents][filter]=&amp;ctf[Documents][view]=</title><style type="text/css">body { background-color:#eee; margin:0; padding:0; font-family:Helvetica,Arial,sans-serif; }.info { border-bottom:1px dotted #333; background-color:#ccdef3; margin:0; padding:6px 12px; }.info h1 { margin:0; padding:0; color:#333; letter-spacing:-2px; }.header { margin:0; border-bottom:6px solid #ccdef3; height:23px; background-color:#666673; padding:4px 0 2px 6px; background-image:url(http://localhost/lapford/cms/images/mainmenu/top-bg.gif); }.trace { padding:6px 12px; }.trace li { font-size:14px; margin:6px 0; }pre { margin-left:18px; }pre span { color:#999;}pre .error { color:#f00; }.pass { margin-top:18px; padding:2px 20px 2px 40px; color:#006600; background:#E2F9E3 url(http://localhost/lapford/cms/images/alert-good.gif) no-repeat scroll 7px 50%; border:1px solid #8DD38D; }.fail { margin-top:18px; padding:2px 20px 2px 40px; color:#C80700; background:#FFE9E9 url(http://localhost/lapford/cms/images/alert-bad.gif) no-repeat scroll 7px 50%; border:1px solid #C80700; }.failure span { color:#C80700; font-weight:bold; }</style></head><body><div class="header"><img src="http://localhost/lapford/cms/images/mainmenu/logo.gif" width="26" height="23" /></div><div class="info"><h1>Website Error</h1><h3>There has been an error</h3><p>The website server has not been able to respond to your request.</p></div></body></html>

Avatar
UncleCheese

Forum Moderator, 4102 Posts

23 October 2010 at 2:38am

"There has been an error."

That's not very helpful! Get your site in dev mode so you can see what's up!

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
ajxtee

Community Member, 8 Posts

23 October 2010 at 2:45am

Apologies! Sleep deprived brain was having problems understanding what it was seeing!

Here is the full output:

src="http://localhost/lapford/cms/images/mainmenu/logo.gif" width="26" height="23" /></div><div class="info error"><h1>[User Error] Bad RecordClassName '' and $baseClass not set</h1><h3>POST /lapford/admin/EditForm/field/Documents/UploadifyForm/field/UploadedFiles/upload?ctf[Documents][start]=0&amp;ctf[Documents][per_page]=10&amp;ctf[Documents][showall]=0&amp;ctf[Documents][sort]=&amp;ctf[Documents][sort_dir]=&amp;ctf[Documents][search]=&amp;ctf[Documents][filter]=&amp;ctf[Documents][view]=</h3><p>Line <strong>2762</strong> in <strong>/Applications/XAMPP/xamppfiles/htdocs/lapford/sapphire/core/model/DataObject.php</strong></p></div><div class="trace"><h3>Source</h3><pre><span>2753</span> foreach($records as $record) {
<span>2754</span> if(empty($record['RecordClassName'])) {
<span>2755</span> $record['RecordClassName'] = $record['ClassName'];
<span>2756</span> }
<span>2757</span> if(class_exists($record['RecordClassName'])) {
<span>2758</span> $results[] = new $record['RecordClassName']($record);
<span>2759</span> } else {
<span>2760</span> if(!$baseClass) {
<span>2761</span> user_error(&quot;Bad RecordClassName '{$record['RecordClassName']}' and &quot;
<span>2762</span> <span class="error"> . &quot;\$baseClass not set&quot;, E_USER_ERROR);
</span><span>2763</span> } else if(!is_string($baseClass) || !class_exists($baseClass)) {
<span>2764</span> user_error(&quot;Bad RecordClassName '{$record['RecordClassName']}' and bad &quot;
<span>2765</span> . &quot;\$baseClass '$baseClass not set&quot;, E_USER_ERROR);
<span>2766</span> }
<span>2767</span> $results[] = new $baseClass($record);
<span>2768</span> }
</pre><h3>Trace</h3><ul><li><b>Bad RecordClassName '' and $baseClass not set</b>
<br />
Line 2762 of DataObject.php</li>
<li><b>DataObject-&gt;buildDataObjectSet(MySQLQuery,DataObjectSet)</b>
<br />
Line 745 of File.php</li>
<li><b>File-&gt;instance_get(,,,,DataObjectSet)</b>
<br />
Line 2714 of DataObject.php</li>
<li><b>DataObject::get(File)</b>
<br />
Line 118 of SortableDataObject.php</li>
<li><b>SortableDataObject-&gt;onBeforeWrite(,,,,,,)</b>
<br />
Line 963 of Object.php</li>
<li><b>Object-&gt;extend(onBeforeWrite,)</b>
<br />
Line 829 of DataObject.php</li>
<li><b>DataObject-&gt;onBeforeWrite()</b>
<br />
Line 348 of File.php</li>
<li><b>File-&gt;onBeforeWrite()</b>
<br />
Line 936 of DataObject.php</li>
<li><b>DataObject-&gt;write()</b>
<br />
Line 153 of Upload.php</li>
<li><b>Upload-&gt;load(Array,Uploads/)</b>
<br />
Line 170 of Upload.php</li>
<li><b>Upload-&gt;loadIntoFile(Array,File,Uploads/)</b>
<br />
Line 291 of UploadifyField.php</li>
<li><b>UploadifyField-&gt;upload(SS_HTTPRequest)</b>
<br />
Line 137 of RequestHandler.php</li>
<li><b>RequestHandler-&gt;handleRequest(SS_HTTPRequest)</b>
<br />
Line 155 of RequestHandler.php</li>
<li><b>RequestHandler-&gt;handleRequest(SS_HTTPRequest)</b>
<br />
Line 155 of RequestHandler.php</li>
<li><b>RequestHandler-&gt;handleRequest(SS_HTTPRequest)</b>
<br />
Line 155 of RequestHandler.php</li>
<li><b>RequestHandler-&gt;handleRequest(SS_HTTPRequest)</b>
<br />
Line 155 of RequestHandler.php</li>
<li><b>RequestHandler-&gt;handleRequest(SS_HTTPRequest)</b>
<br />
Line 147 of Controller.php</li>
<li><b>Controller-&gt;handleRequest(SS_HTTPRequest)</b>
<br />
Line 281 of Director.php</li>
<li><b>Director::handleRequest(SS_HTTPRequest,Session)</b>
<br />
Line 124 of Director.php</li>
<li><b>Director::direct(/admin/EditForm/field/Documents/UploadifyForm/field/UploadedFiles/upload)</b>
<br />
Line 127 of main.php</li>
</ul></div></body></html>

Avatar
UncleCheese

Forum Moderator, 4102 Posts

23 October 2010 at 3:11am

Looks like the ClassName field is null? Can you check your DB and look in the File table? Make sure none of the ClassName fields are null.

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
ajxtee

Community Member, 8 Posts

23 October 2010 at 3:22am

That fixed it. There were null ClassNames caused by some problems I had with an ImageUploadField on a totally different page. Not sure why images were still uploading with no problems though?

I'd never have put the two together so thanks UncleCheese!

Avatar
Ryan M.

Community Member, 309 Posts

19 November 2010 at 7:06pm

I'm getting an HTTP_ERROR when trying to use Uploadify on a Multiple file upload. Checked the documentation for Uploadify and tried enabling the debugging, and site is in dev mode. It doesn't provide any useful information and debug doesn't alert to any errors when attempting an upload.

Go to Top