1

I have checked all other questions on stack exchange with similar titles and they don't seem to help my situation. I have added assets sources to craft CMS. but when uploading I get the following error:

The error message was: "Error uploading the file: The file system path "{siteUrl}assets/images/hero-images/" set for this source does not exist."

I am working locally using MAMP. I do not have multiple environments. only local.

the siteUrl variable seems to work fine when used directly in templates. just doesn't work for assets.

File system path is

assets/images/hero-images/

URL is

{siteUrl}assets/images/hero-images/

General config is set to

return array(

    // Base site URL
    'siteUrl' => "//projectname:8888/html/",

    // Environment-specific variables (see https://craftcms.com/docs/multi-environment-configs#environment-specific-variables)
    'environmentVariables' => array(),

    // Default Week Start Day (0 = Sunday, 1 = Monday...)
    'defaultWeekStartDay' => 0,

    // Enable CSRF Protection (recommended, will be enabled by default in Craft 3)
    'enableCsrfProtection' => true,

    // Whether "index.php" should be visible in URLs (true, false, "auto")
    'omitScriptNameInUrls' => 'auto',

    // Control Panel trigger word
    'cpTrigger' => 'admin',

    // Dev Mode (see https://craftcms.com/support/dev-mode)
    'devMode' => false,

);

If I open the assets in chrome, this is their file path.

http://projectname:8888/html/assets/images/hero-images/be-inspired-mobile.jpg

This is driving me mad and have checked everything.

I am using exactly the same config settings as all my other sites which work absolutely fine. Any help will be really appreciated :)

1 Answer 1

1

As per the Craft Docs at https://craftcms.com/docs/multi-environment-configs#environment-specific-variables, add a basePath (or other name) variable to you config. For MAMP, it should look something like:

'basePath' => '/Applications/MAMP/htdocs/example.dev/public/'

Then in your asset source settings, change File System Path to:

{basePath}assets/images/hero-images/

2
  • Unfortunately this didn't seem to work. Also using MAMPs given url (//projectname:8888/html/) as {siteUrl} seems to work fine in all my other projects. I also do not keep my sites in MAMPS htdocs folder, i keep them in a separate 'sites' folder so that I can work on more than one at once. Aug 23, 2017 at 8:03
  • 1
    Andrea's answer is definitely correct. Any time you have {tag}s within your asset sources' File System Path or URL settings, their values will be swapped out with the environment-specific variables, which are defined by the environmentVariables array in general.php. Your array is empty, so it's expected that it wouldn't work for you. Aug 23, 2017 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.