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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

UploadField path error

Go to End

5 Posts   1056 Views


Community Member, 16 Posts

3 June 2013 at 9:52am

hi all.
the error is that the uploadfield is saving the file in the rigth folder (temas), i check and the file is saved ok. but when in the template I link the file with $link or $URL the path is wrong, is like was saved to the folder assets/ and not to the folder assets/temas.

here the code.

class Musica extends Page {

	static $db = array(

	static $has_many = array(
		'Canciones' => 'File'

	public function getCMSFields() {
		$fields = parent::getCMSFields();
		$canciones = new UploadField('Canciones');
		$canciones->getValidator()->allowedExtensions = array('mp3', 'wav');
		$fields->addFieldToTab("Root.Canciones", $canciones);
		return $fields;
class Musica_Controller extends Page_Controller {

// and in the template 

<% control $Canciones %>
	<div >
		$Link- $URL//both throw the path to the file in the folder assetst/

<% end_control %>

is like the record saved at the file table in the db is not taking care the folder that was saved the file.

can any body help me?

the version of SS is 3.0.5.



Community Member, 254 Posts

3 June 2013 at 7:28pm

Edited: 03/06/2013 7:28pm

Hi again,

I'm not 100% why this isn't working, but you could try $AbsoluteURL and make sure you ?flush=all
Also double check in the DB, making sure the correct path is saved in there

SELECT id,filename FROM ssdb.File ORDER BY id DESC;


Community Member, 16 Posts

4 June 2013 at 7:08am

Edited: 04/06/2013 7:56am

hi again Bambii7 seems I'm the only with this problem :S.

the $AbsoluteURL returns an incorrect path to the file too.

I check the table File in the DB and the UploadField is saving the file with the incorrect path, but the file is saved in the correct folder

example if I upload a file called song.mp3.

the file is saved at the folder: assests/temas/song.mp3 but the record filename in the db is assests/song.mp3.

ignores the folder where the file was saved.


Community Member, 254 Posts

4 June 2013 at 2:09pm

Umm lastly what are the permissions of the assets folder and an example uploaded image, it is possible they're able to write but unable to read the file.


Community Member, 16 Posts

5 June 2013 at 5:11am

Hi bambii7 the permissions of the assets folder and the assets/temas are 755
the permissions on an example uploaded file to the assets/temas are 644.

The fix that Im using is to manually set the path to the file in the template.

<a href="assets/temas/$Name">$title</a>