10386 Posts in 2198 Topics by 1712 members
| Go to End | Next > | |
| Author | Topic: | 1738 Views |
-
Duplicate files when uploading with filemanager

5 June 2009 at 8:47am Last edited: 5 June 2009 8:50am
Hi there,
I'm using the following code in Page.php so that I can use filemanager module to attach images to every page:
static $has_many = array(
'Images' => 'Image'
);public function getCMSFields() {
$fields = parent::getCMSFields();$manager = new HasManyFileManager(
$this,
'Images', // name -> will be used for file grouping
'Images' // relation name defined in $has_many
);// creating tab for the "Files" Manager
$fields->addFieldToTab('Root.Content.Images', $manager);
return $fields;
}public function onBeforeDelete(){
parent::onBeforeDelete();
$this->deleteAttachedFiles();
}Everything works perfect, except for one thing. All images that I upload are stored in two folders, being /Uploads and /Uploads/AttachedFiles/Images. This doesn't feel right, shouldn't images only be stored in /Uploads/AttachedFiles/Images ?
As there will be a lot of large images on this site, I would really like this solved, because this will cost me twice as much disk space...
-
Re: Duplicate files when uploading with filemanager

5 June 2009 at 9:50am
Hi
Yes, that sounds strange indeed. I didn't encounter such behavior yet. Can you post the SilverStripe Version you're using, together with other modules you got installed?
-
Re: Duplicate files when uploading with filemanager

5 June 2009 at 7:25pm
SilverStripe CMS 2.3.1
Modules installed:
- filemanager 0.3.2
- cmsworkflow r78072
- dataobject_manager r137
- swfupload r128
- userforms 0.1.0I have been checking another SilverStripe project of mine and found that same issues occurs at that site.
Thanks for your help!
-
Re: Duplicate files when uploading with filemanager

5 June 2009 at 7:27pm
PS. When removing an attached image the file is removed from Uploads/AttachedFiles/Images but NOT from Uploads/
-
Re: Duplicate files when uploading with filemanager

5 June 2009 at 7:56pm
I don't get this behavior on 2.3.1. But since you're using SWFUpload and DataObjectManager, why not migrate completely to the DataObjectManager?
-
Re: Duplicate files when uploading with filemanager

5 June 2009 at 8:22pm Last edited: 8 June 2009 6:14am
I will do this, as problems got worse. Very strange.
Just for your info: I removed all pages from mysite/code except for Page.php. Next, I ran a clean install leaving the modules mentioned above in place. Now when going into the CMS and creating a new page I can not delete this page: 'Delete from draft' returns a 'Server error' and the page is NOT deleted. I have narrowed this down and I the problem no longer occurs when removing these lines:
public function onBeforeDelete(){
parent::onBeforeDelete();
$this->deleteAttachedFiles();
} -
Re: Duplicate files when uploading with filemanager

9 June 2009 at 10:16am
Dear Banal, could you please have another look.
Am working on a different project with FileManager only (no DataObjectManager module here) and again... files are stored in both the Uploads/ folder and in Uploads/AttachedFiles/Bikers folders. Same issue on different site: duplicate files. What am I doing wrong?
class TeamPage extends Page {
public static $db = array(
);
public static $has_one = array(
'Video' => 'File',
'PreviewImage' => 'Image'
);static $has_many = array(
'Images' => 'Image'
);static $allowed_children = array(
'TeamMemberPage',
'SponsorPage'
);public function getCMSFields() {
$fields = parent::getCMSFields();
$manager = new HasManyFileManager(
$this,
'Teams', // name -> will be used for file grouping
'Images' // relation name defined in $has_many
);
$fields->addFieldToTab('Root.Content.Images', $manager);$fields->addFieldToTab("Root.Content.Video", new FileIFrameField('Video'));
$fields->addFieldToTab("Root.Content.Video", new ImageField('PreviewImage', 'Preview Image (shown before video starts)'));return $fields;
}/**
* Implementation of the onBeforeDelete Method for FileManager
*/
public function onBeforeDelete(){
parent::onBeforeDelete();
$this->deleteAttachedFiles();
}}
Installed modules (SS 2.3.1):
* Blog
* Filemanager
* Googlesitemaps
* UserformsPls help!
-
Re: Duplicate files when uploading with filemanager

9 June 2009 at 9:28pm
Hi klikhier
I was indeed able to reproduce the problem. I fixed the bug in trunk, please get the "Latest trunk build" here: http://silverstripe.org/has-many-file-manager-module/
Hopefully that fixes your problem.
| 1738 Views | ||
| Go to Top | Next > |


