asongo
Posts: 19
|
| Posted: 07/18/2007, 2:48 AM |
|
Is it possible to set different file folder depends on other field's value?
ie: upload/2110, upload/2320,depends on user's department
I want to store the uploaded files into different folders depend on user's department
_________________
PHP 4.4x ,MySQL 4.0x
Kaohsiung,Taiwan |
 |
 |
kirchaj
Posts: 215
|
| Posted: 07/18/2007, 6:30 AM |
|
Asongo,
This can be done with custom coding. I use the beforeprocessfile event and set the upload directory based on the student's id. The code looks like
//NewRecord1_FileUpload1_BeforeProcessFile @7-98B1A77B
function NewRecord1_FileUpload1_BeforeProcessFile(& $sender)
{
$NewRecord1_FileUpload1_BeforeProcessFile = true;
$Component = & $sender;
$Container = & CCGetParentContainer($sender);
global $NewRecord1; //Compatibility
//End NewRecord1_FileUpload1_BeforeProcessFile
//Custom Code @17-2A29BDB7
// -------------------------
// Write your own code here.
global $NewRecord1;
$NewRecord1->FileUpload1->FileFolder = "/var/www/html/portfolio/uploads/" . CCGetUserLogin() . "/";
// -------------------------
//End Custom Code
You would have to look up the department and set the folder to that location.
Hope this helps a little.
TK
|
 |
 |
asongo
Posts: 19
|
| Posted: 07/18/2007, 7:09 AM |
|
Thank you very much, kirchaj,it is exactly what I need.
_________________
PHP 4.4x ,MySQL 4.0x
Kaohsiung,Taiwan |
 |
 |
AQUANANU
Posts: 107
|
| Posted: 07/19/2007, 3:29 AM |
|
this does work for uploading files, but if have to delete the file uploaded for the record, the file upload component doesnt give the same option, it is unable to verify the existance of the file on the server.
Is there any way that we can add a event to the file upload component, that is before initialise, to set the value of the file folder, or the option for having file folder source from database.
_________________
Navneet Kakkar
CEO
Positive Thinker's Inc. |
 |
 |
Wkempees
|
| Posted: 07/19/2007, 4:22 AM |
|
alter your table to not only hold the file name
but also location (folder) size and type
The last two I always collect from the (php) fileupload.
It gives me the advantage (see other posts) of being
able to display filesize to my user without having to use any filesystem
routines upon presentation.
But back to the topic at hand, store the created filepath along with the
filename.
GL,
Walter
|
|
|
 |
asongo
Posts: 19
|
| Posted: 07/19/2007, 7:22 PM |
|
If save the uploaded file folder path in database,how to set the "File Folder" property on design mode or runtime ?
_________________
PHP 4.4x ,MySQL 4.0x
Kaohsiung,Taiwan |
 |
 |
Wkempees
|
| Posted: 07/20/2007, 6:50 AM |
|
concatenate them in the SQL
suppose you have a form now displaying the file name.
Then in the SQL it will be select filename from table.
Alter the sql to select filepath & filename as filename from table
check your SQL manual for correct concatenate syntax.
in MySQL it would be Select concat(filepath,filename) as filename
or if you need to add a slash
Select concat(filepath,'/',filename) as filename
Walter
|
|
|
 |
asongo
Posts: 19
|
| Posted: 07/23/2007, 2:59 AM |
|
Thanks,Walter:
I modified the SQL in the "Open Method" section as follow: Quote :
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeBuildSelect", $this->Parent);
$this->SQL = "SELECT serino, folder, concat(folder,file_name) as file_name, remark, EMPNO, upload_date, DEPT, category_id \n" .
"FROM garden_upload\n" .
"WHERE serino = " . $this->SQLValue($this->wp->GetDBValue("1"), ccsInteger) . " ";
$this->Order = "";
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "BeforeExecuteSelect", $this->Parent);
$this->PageSize = 1;
$this->query($this->OptimizeSQL(CCBuildSQL($this->SQL, $this->Where, $this->Order)));
$this->CCSEventResult = CCGetEvent($this->CCSEvents, "AfterExecuteSelect", $this->Parent);
}
//End Open Method
but still got the same error message,am I misunderstood ?
_________________
PHP 4.4x ,MySQL 4.0x
Kaohsiung,Taiwan |
 |
 |
Wkempees
|
| Posted: 07/23/2007, 6:01 AM |
|
I am not an ASP, I gave you PhP/MySQL directions, stating to follow
manual for your DB.
Q1: what are you using ASP obviously, so mayve SQL Server as well?
Q2: what same error message?
Walter
|
|
|
 |
asongo
Posts: 19
|
| Posted: 07/23/2007, 5:13 PM |
|
"ASP" ? I am using PHP/MySQL ,Apache server. and the error message means it is unable to verify the existance of the file on the server.(upload/2110/1/200707240754010.asongo.jpg)
even I concat the folder and filename as filename.
ASONGO
_________________
PHP 4.4x ,MySQL 4.0x
Kaohsiung,Taiwan |
 |
 |
wkempees
|
| Posted: 07/25/2007, 2:58 AM |
|
Ok, so you will have to change strategy.
In stead of storing the filepath and filename, store the concatenated
filepath and name as well as the missing slash(!?)
in the field 'filename' after upload.
"asongo" <asongo@forum.codecharge> schreef in bericht
news:246a5440e2ec8b@news.codecharge.com...
> "ASP" ? I am using PHP/MySQL ,Apache server. and the error message means
> it is unable to verify the existance of the file on the
> server.(upload/2110/1/200707240754010.asongo.jpg)
> even I concat the folder and filename as filename.
>
> ASONGO
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
|