This topic is locked
[SOLVED]

  Store Files Outside Phprunner Directory

5/5/2013 8:16:21 AM
PHPRunner General questions
S
shoppy author

I have a Hosting contract with only 4GB of webspace.
Now I have my own server with lots of space but PHPRunner needs to run on the server of the Hosting Company (because of the IP adress). But I like to store the documents on my own server.
Is this possible?

C
cgphp 5/5/2013

In the "Before record added" event, open a ftp connection and put each file to the new storage. You can get inspiration from these manual pages: http://xlinesoft.com/phprunner/docs/upload_files_to_users_folders.htm, http://www.php.net/manual/it/function.ftp-put.php

S
shoppy author 5/6/2013



In the "Before record added" event, open a ftp connection and put each file to the new storage. You can get inspiration from these manual pages: http://xlinesoft.com/phprunner/docs/upload_files_to_users_folders.htm, http://www.php.net/manual/it/function.ftp-put.php


Thanks Cristian,
I use PHPRunner 4.2 and the code " foreach( $pageObject->filesToMove as $key=>$val)" gives an error.

it says "Invalid argument supplied for foreach()"

This is part of the code from the manual you gave me, but thats for 6.2. Can we change this code to one that 4.2 understands?
First I am trying to get this part to work and then we will try to store the files on another server outside the PHPRunner server.

(I have send you an PM about that one)

Admin 5/6/2013

Shoppy,
you need to check corresponding article in PHPRunner 4.2 manual. It should come with a relevant code sample.

S
shoppy author 5/6/2013



Shoppy,
you need to check corresponding article in PHPRunner 4.2 manual. It should come with a relevant code sample.


Sorry Sergey,
Can't find it. I was looking for it before and couldn't find it then.

Admin 5/6/2013

It's quite possible that PHPRunner 4.2 didn't expose access to uploaded files via events. I would consider upgrading to accomplish this task.

S
shoppy author 5/9/2013

I just keep on trying to get it to work.
But encountered this problem:



// Before record added

function BeforeAdd(&$values,&$message,$inline)

{

//username is used as directory name
global $pageObject;
foreach( $pageObject->filesToMove as $key=>$val)
{
if($pageObject->filesToMove[$key]->sourceFilename==$_FILES["value_Document_".postvalue("id")]["tmp_name"])
{
//create directory if don't exist
$dirname= "projectstukken/".$_SESSION["GebruikersID"];
if (is_dir($dirname)) {
} else {
mkdir("projectstukken/".$_SESSION["GebruikersID"], 0777);
}
$pageObject->filesToMove[$key]->destFilename =
$_SESSION["GebruikersID"]."/".$values["Document"];
}
}
$values["Document"] = $_SESSION["GebruikersID"]."/".$values["Document"];

} // function BeforeAdd


The name of the field that contains the documants name is "Document".

The GebruikersID (UserID) is of course just a number.
The code above gives the error "Trying to get property of non-object" it is in the line where the code says "foreach( $pageObject->filesToMove as $key=>$val)" So there must be an object or property of an object that is not defined. But what object?
Besides that I would like the directories gets the name of the User (Gebruiker).

In the Users Table is a field called 'Naam'. Is it possible to change the code above in such a way that the directory gets the name of the user that is logged in?
Many thanks
John

C
cgphp 5/9/2013

Did you follow the Sergey hint?

S
shoppy author 5/9/2013



Did you follow the Sergey hint?


You mean upgrading to 6.0 ?

No sorry, I cant afford it right now.

C
cgphp 5/9/2013

As Sergey said, it's quite possible that PHPRunner 4.2 didn't expose access to uploaded files via events. It's possible the code above will never work.

S
shoppy author 5/9/2013

Yeah, that could be the case.
But is there no code we can implant in the Edit and View settings that refers to the designed folder?

If I make al the folders in the name of the users (users are limited and cannot be made outside of admin)we only have to direct there.
Or am I thinking to simple Cristian?

C
cgphp 5/9/2013

Yes, you can code your custom solution. Check this page: http://php.net/manual/en/function.move-uploaded-file.php

S
shoppy author 5/9/2013



Yes, you can code your custom solution. Check this page: http://php.net/manual/en/function.move-uploaded-file.php


Thanks for your help Cristian, I really mean that but this is way to difficult for me.
I implanted a combination of DropBox (because of the iphone/pad and android app) and FTPBox in the system.

Gave all the users (Rayon1, Rayon2 ... ec.) an FTP entry and they must upload and download their files from there own designated directories.
But maybe this is not possible with 4.2

Because this project is for a group of volunteers I cannot buy an upgrade of PHPRunner.
Maybe I need to find a different way to do this.
If you can help me with the programming of this in PHP I would be very grateful, if not, I will understand.
John

S
shoppy author 6/11/2013

[Solved]
You just have to manually change the event file.
In the 'include' folder you have to find the event file that handles your documents.

In my case it was the include/_Projectstukken_settings.php ducument.
Around line 105 you find this line $fdata["UploadFolder"]="your dir/";

Change it in $fdata["UploadFolder"]="your dir/".$_SESSION["UserID"];

(rename "your dir" into the name of the directory where you store your files)
Of course you have to manually add the right folders.
That's all.