Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » 'HTTP Error' Uploading Documents using FileDataObjectManager

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2 3 4 5 6
Go to End
Author Topic: 6894 Views
  • ajxtee
    Avatar
    Community Member
    8 Posts

    'HTTP Error' Uploading Documents using FileDataObjectManager Link to this post

    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;
       }
    }

  • UncleCheese
    Avatar
    4085 Posts

    Re: 'HTTP Error' Uploading Documents using FileDataObjectManager Link to this post

    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

  • ajxtee
    Avatar
    Community Member
    8 Posts

    Re: 'HTTP Error' Uploading Documents using FileDataObjectManager Link to this post

    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>

  • UncleCheese
    Avatar
    4085 Posts

    Re: 'HTTP Error' Uploading Documents using FileDataObjectManager Link to this post

    "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

  • ajxtee
    Avatar
    Community Member
    8 Posts

    Re: 'HTTP Error' Uploading Documents using FileDataObjectManager Link to this post

    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>

  • UncleCheese
    Avatar
    4085 Posts

    Re: 'HTTP Error' Uploading Documents using FileDataObjectManager Link to this post

    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

  • ajxtee
    Avatar
    Community Member
    8 Posts

    Re: 'HTTP Error' Uploading Documents using FileDataObjectManager Link to this post

    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!

  • Ryan M.
    Avatar
    Community Member
    309 Posts

    Re: 'HTTP Error' Uploading Documents using FileDataObjectManager Link to this post

    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.

    6894 Views
Page: 1 2 3 4 5 6
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.