7911 Posts in 1354 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Uploadify: Several different errors with same config
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1068 Views |
-
Uploadify: Several different errors with same config

16 September 2010 at 6:02am Last edited: 16 September 2010 6:04am
I'm getting several problems with the Uploadify-Module on the same page with the same code.
I wrote two new Resources:mysite/code/BrochureResource.php
<?php
class BrochureResource extends DataObject
{
static $db = array (
'Title' => 'Text'
);static $has_one = array (
'Page' => 'Page',
'Attachment' => 'File'
);}
and mysite/code/SimulationResource.php<?php
class SimulationResource extends DataObject
{
static $db = array (
'Title' => 'Text'
);static $has_one = array (
'Page' => 'Page',
'Attachment' => 'File'
);}
In my ReferencePage.php I have the following code:class ReferencePage extends Page {
static $db = array(
...
);
static $has_one = array(
...
'Simulation' => 'SimulationResource',
'Brochure' => 'BrochureResource',
'LayoutPhoto' => 'Image'
);function getCMSFields() {
$fields = parent::getCMSFields();// Adding a Brochure
$brochure = new FileUploadField(_t('VEHICLEPAGE.BROCHURE','Brochure.Attachment'));
$brochure->removeFolderSelection();
$brochure->uploadFolder = 'brochure/'.$this->URLSegment;
$brochure->setFileTypes(array('pdf'),_t('VEHICLEPAGE.PDFS','PDFs'));
$fields->addFieldToTab("Root.Content.Main", $brochure, 'Content');
// Adding a Simulation
$simulation = new FileUploadField(_t('VEHICLEPAGE.SIMULATION','Simulation.Attachment'));
$simulation->removeFolderSelection();
$simulation->uploadFolder = 'simulations/'.$this->URLSegment;
$simulation->setFileTypes(array('exe'),_t('VEHICLEPAGE.EXES','EXEs'));
$fields->addFieldToTab("Root.Content.Main", $simulation, 'Content');// Adding a Layout-Image
$layoutphoto = new ImageUploadField(_t('VEHICLEPAGE.LAYOUTPHOTO','LayoutPhoto'));
$layoutphoto->removeFolderSelection();
$layoutphoto->uploadFolder = 'layout_images/'.$this->URLSegment;
$fields->addFieldToTab("Root.Content.Main", $layoutphoto, $techspecs);....
....// Return fields to CMS_Main
return $fields;
}}
But when I try to upload files with the fields, I get on the first (Brochure) an IO-Error, the second one (Simulation) uploads the file and shows an HTTP-Error when using EXE-Files (if I allow different ones, this field works) and the third (Layout-Image) lets me pick a file but doesn't upload it without showing any errors.
Does somebody (Uncle Cheese) have an idea? (I'm using the trunk builds from today)
-
Re: Uploadify: Several different errors with same config

16 September 2010 at 6:16am
OK, lots going on here.
First, most hosting providers won't allow you to upload executable files to a directory that is writable by the public. So I would forget the "exe" or "php" files.. That will almost always throw a 500.
Second, your upload fields are not constructed properly. You're missing the first argument, which should be the relation that the upload field is managing. You're passing a translated string as the first argument. That should come second.
--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com -
Re: Uploadify: Several different errors with same config

16 September 2010 at 6:39am
Thank you, now everything works properly. Seems MAMP doesn't allow exes with standard-config. I'll test it on the live-server later.
| 1068 Views | ||
|
Page:
1
|
Go to Top |
