ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Safecracker File and Relative Paths

April 15, 2011 12:25pm

Subscribe [3]
  • #1 / Apr 15, 2011 12:25pm

    AJP

    311 posts

    Hey gang.

    I’m setting up relative paths for all my file upload directories. Or trying. I’m also masking my CP.
    If I use the native file upload method, everything works fine.

    So my file upload server path is (./files/pages).
    URL is (/files/pages).

    With native File, this works fine.

    However, using SafeCracker File, there’s some sort of bug with how it accesses relative file paths.
    Erik Reagan (so helpful that guy!) helped me deduce that if I comment out the conditional on line 574 of ft.safecracker_file.php

    if ( ! preg_match('#^(/|\w+:[/\\\])#', $server_path))
            {
                $server_path = realpath(APPPATH.'../'.$server_path).'/';
            }

    I’m able to see the files I’m looking for in the file upload directory I’ve specified. But that was only a debugging test.
    I’ve switched to the regular file upload method for the time being.

    Any help, or notes on this?
    Thanks!

  • #2 / Apr 15, 2011 1:16pm

    AJP

    311 posts

    I’ve found a solution for the time being.

    If I set my Server Path to: ../public_html/files/pages/

    Then everything works as expected.
    So it would appear that the server path is relative to the system directory.

  • #3 / Apr 17, 2011 12:39pm

    Greg Salt

    3988 posts

    Hi AJ,

    Thanks for the update and glad that you got this sorted out. I’m not sure whether this is just something that needs to be clarified in the SC user guide so I’ll check up on that. I’ll go ahead and close this now but please open a related thread if required.

    Cheers

    Greg

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases