Announcement

Collapse
No announcement yet.

Image path question

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Image path question

    I need to know if the Image Folder property (for Image/File) type refers to the folder originating from Application root OR Porject root ?

    Let's say my Project path is: www.mysite.com/project1
    The path for first From is: www.mysite.com/project1/form1
    The path for second From is: www.mysite.com/project1/form2

    I want path for images to be shared between From1 and Form2

    I'm copying an image path (stored in the record) from Table1(Path1) which is stored by From1
    the actual path is: "www.mysite.com/project1/images/thumbs" , so in the Image field I enter: "images/thumbs" (not sure if I need preceding and trailing / ?)

    TO
    Table2(Path2) which is stored by From2

    Would Form2 refer to the same path as Form1 ?




    Another words - what's the best solution to keep consistent image path for several Apps within the same Project ?

    Arthur
    -----------------------------------------
    Arthur Klisiewicz
    dATA POINT SOFTWARE
    www.datapointsoftware.com

  • #2
    aka,

    Dunno if this helps - I use the snippet below in my login app's onApplicationInit event to set the filepath for the location of files (not images), but principal would be the same images. I'm using Linux Dev & Prod servers, so if you are Windows the paths may differ a bit. I set a global var [fp] to the filepath of where my uploaded docs live, depending on whether it is running on a dev instance (I have 2 dev instances - SC7 and SC8) or a prod server.

    You just need to change the /file/doc/ bit to /file/img/ I think. BTW - In the app that uploads the files there is a setting on the main setting's page for that upload field where I have a subdirectory set as "/timesheets".

    I'm also setting a [prod] global var to identify if dev or prod because some other (unrelated) behaviour differs depending on whether running on dev or prod.


    Code:
    // Identify if running on Prod or Dev environment and set filepath var
    if ((substr($_SERVER['HTTP_HOST'],-4) == '8083') OR (substr($_SERVER['HTTP_HOST'],-4) == '8099')) {	// Current Port?
    	[prod] = FALSE;
    	[fp] = "../../../file/doc/timesheets/";
    
    } else {
    	[prod] = TRUE;
    	[fp] = "../_lib/file/doc/timesheets/";
    }
    Apologies though if I'm barking up the wrong tree.

    Comment


    • #3
      adz1111 - your suggestions are helpful. I just wonder if you use global VAR what do you store as path ?
      assuming the App is always store on the same domain one can use: http://www.mydomain.com/project1/files/....

      I wonder is I just use: [glo_filepath]=[glo_domain]&[glo_folder] having [glo_folder] set to "files" would work ?

      I'm looking at your code and it's clear except: $ _SERVER['HTTP_HOST'] - is "http_host" some internal variable ?
      and so when running locally SC does not use ports 8083 and 8099 ?

      Arthur
      -----------------------------------------
      Arthur Klisiewicz
      dATA POINT SOFTWARE
      www.datapointsoftware.com

      Comment


      • #4
        Hi aka (sorry for delay, been away for a few days)

        I just wonder if you use global VAR what do you store as path ?
        assuming the App is always store on the same domain one can use: http://www.mydomain.com/project1/files/....
        Not sure what you're asking. In terms of including the full domain name in the path - no I do not. The way [fp] is set allows me to use that code for any project, regardless of the domain name. The number of "../"s may differ depending how "deep" under the main domain I deploy the prod environment. That said, I do not see any reason not to use a path as you have above.

        I wonder is I just use: [glo_filepath]=[glo_domain]&[glo_folder] having [glo_folder] set to "files" would work ?
        Yep - don't see why not. I don't think it matters how you build the path. The slightly tricky bit is experimenting to ensure that you know what the path needs to actually be - then build it how you like.

        I'm looking at your code and it's clear except: $ _SERVER['HTTP_HOST'] - is "http_host" some internal variable ?
        and so when running locally SC does not use ports 8083 and 8099 ?
        Yes - its a PHP super-global variable (see http://php.net/manual/en/reserved.variables.server.php for details). It is available wherever PHP (as opposed to SC) is running. I have 2 development SC environments (SC7 and SC8) - SC7 dev runs under port 8083, and SC8 dev is under 8099. My prod environment is neither of those ports - so that's how I tell them apart. My dev environments have a different path to my prod environment (which is hosted).

        Hope that helps.

        Comment

        Working...
        X