This topic is locked

Uploading files, changing files folder location and creating subfolder

9/30/2009 12:57:54 PM
PHPRunner General questions
jwoker author

I have 2 projects using the same DB and they need to share a common files folder, how can I make the location of the files folder relative to /public_html rather than the projects root folder?
Also, I am working on the before record added event code below. It works only if I include the subfolder path in the files name_field, so that the name field and hyperlink will read "subfolder/filename". In my project, the subfolder name will always be the associated job_name field, and I would like the records name field to just be file "filename" and the hyperlink be to "job_name/filename". I think the answer to this question may be dependent on the solution for my first issue.

//Job name is used as directory name
global $files_move, $conn;
$strSQLjobname = "select job_name from job where id='".$values["job_id"]."'";

$rsExists = db_query($strSQLjobname,$conn);

$data=db_fetch_array($rsExists);
foreach( $files_move as $key=>$val)
{
if($val[0]==$_FILES["file_name"]["tmp_name"])
$files_move[$key][1] = "jobfiles/".$data["job_name"]."/".$values["name"];
}

$values["name"] = $data["job_name"]."/".$values["name"];
return true;
J
Jane 10/1/2009

Hi,
you create new folder under public_html directory. Then point PHPRunner to this directory editing file path on the "Edit as" settings dialog.

Here are some examples of URL prefix usage:

http://www.xlinesoft.com/phprunner/docs/_view_as__settings.htm#file
Then edit your code in the Before record added event.

jwoker author 10/2/2009

Thanks, I now have the files directory located outside of the /public_html and the following code works to create a file name including my "job_name". The event code will also create a sub-directory for a "job_name" if it does not already exist. 2 problems I am having are: 1) when the event code creates a directory it sets permissions to 755 rather than 777 like I have the mkdir function setup to do? I also can't delete the directories via cpanel so I'm thinking it is some kind of ownership problem and I might have to create job directories manually <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=44420&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' />
2)Once I get the event code putting files into a sub-directory of my files directory I am going to need to include the values["job_name"] path in the View As box for "Folder where file resides" something like = ../../jobfiles/$values["job_name"] = I need to know the proper way to get the job_name value into that box.

//Job name is used as directory name
global $files_move;
if (!file_exists("../../jobfiles/".$values["job_name"]))

{

mkdir("../../jobfiles/".$values["job_name"], 0777);

}

foreach( $files_move as $key=>$val)

{

if($val[0]==$_FILES["file_name"]["tmp_name"])
$files_move[$key][1] = "../../jobfiles/".$values["job_name"]."_".$values["name"];

}
$values["name"] = $values["job_name"]."_".$values["name"];