Gena
Posts: 591
|
Posted: 10/06/2011, 10:04 AM |
|
I am using FileUpload component but need to change (and then of course save it into table field) name that create component.
Now by default it create uploaded name like
timestamp.originalname.ext and it put in DB table.
but I need to change it like
\mydirname\timestamp.originalname.ext
how I can do it?
_________________
Gena |
|
|
Gena
Posts: 591
|
Posted: 10/13/2011, 9:35 AM |
|
anyone?
_________________
Gena |
|
|
benjohn
Posts: 30
|
Posted: 10/13/2011, 7:07 PM |
|
hi there Gena,
Good Day!
you want to append \mydirname\ to be stored in the tables? hmm is this for the purpose of displaying it later on? if so you could leave it as it is. all you have to do is when you display it, you could use the image component <img src="/mydirname/{image_Src}"> or if you do want to save the directory name then i think you could also use
$table->FileUpload1->SetValue("/mydirname/".$table->FileUpload1->GetFileName());
just an idea that you could try, i am not sure if the second one works though as i normally use the first approach. hope this helps... all the best!
pal,
Benjohn
_________________
~=~=~=~=~=~=~=~=~=~=~=
get it done. make it happen.
~=~=~=~=~=~=~=~=~=~=~= |
|
|
Gena
Posts: 591
|
Posted: 10/13/2011, 11:54 PM |
|
thanks benjohn,
the problem I can't use <img src="/mydirname/{image_Src}"> because path are written in DB already - I am using DB from my customer and can't change this.
so I need to store it into file name in the table like \mydirname\timestamp.originalname.ext
I have tried also this
$table->FileUpload1->SetValue("/mydirname/".$table->FileUpload1->GetFileName());
and it doesn't work
the problem is in the FileUpload component logic. For some reason Record will be updated first (so file name field will be filled first!) and then it process uploading !
and if you change file name in the FileUpload component then you get error
File not found....
because names from Record info and from FileUpload component are different!
_________________
Gena |
|
|
datadoit
|
Posted: 10/14/2011, 6:05 AM |
|
Gena there are many file upload component properties that you have
access to. Start here:
http://docs.codecharge.com/studio40/html/Components/RTP...Folder.html?toc
You'll typically alter these values in a BeforeProcessFile event.
|
|
|
Gena
Posts: 591
|
Posted: 10/14/2011, 6:13 AM |
|
thank datadoit,
I know these. but read my last post!
if you not sure about this try to create a small project and implement what I have asked. You will see it by yourself.
_________________
Gena |
|
|
benjohn
Posts: 30
|
Posted: 10/14/2011, 6:20 AM |
|
Hi there Gena,
Good Day!
i think it is WHERE you put your codes. datadoit pointed out to try to put it in the BeforeProcessFile event of the FileUpload component so i just want to kinda emphasize. hope this helps... all the best!
pal,
Benjohn
_________________
~=~=~=~=~=~=~=~=~=~=~=
get it done. make it happen.
~=~=~=~=~=~=~=~=~=~=~= |
|
|
Gena
Posts: 591
|
Posted: 10/14/2011, 6:26 AM |
|
benjohn, it doesn't matter.
try it by your self!
_________________
Gena |
|
|
datadoit
|
Posted: 10/14/2011, 6:43 AM |
|
You'll want to let the form get processed as normal, then add an event
in AfterInsert/Update to change that database field value.
Recognize that you'll also now need to adjust how the FileUpload
component loads to deal with that prepended folder value. Since the
prepended folder will be in the database table field's value, you'll
need to check for that value before altering that value in step one above.
I've done this many many times, and the specifics are beyond a free
forum post. If you're still stuck, then open an account at
www.codechargesupport.com and we'll get you going, but unfortunately not
for free.
|
|
|
Gena
Posts: 591
|
Posted: 10/14/2011, 6:50 AM |
|
hi datadoit,
I am tired to search solution , I have tried many times, many places etc. no luck.
thank you for your offer but I solved this in other way.
and again, I can assert that it is not possible to make what I need in the Record+UploadFile...
_________________
Gena |
|
|
benjohn
Posts: 30
|
Posted: 10/14/2011, 7:29 AM |
|
Quote Gena:
benjohn, it doesn't matter.
try it by your self!
actually i have but that was long time ago when i was just beginning to learn CCS that is why i could not remember. well, i changed my approach to the first one i suggested hence i am not bothered with this scenario anymore. anyhow good luck with your project... all the best!
pal,
Benjohn
_________________
~=~=~=~=~=~=~=~=~=~=~=
get it done. make it happen.
~=~=~=~=~=~=~=~=~=~=~= |
|
|
benjohn
Posts: 30
|
Posted: 10/14/2011, 7:36 AM |
|
hi there Gena,
another approach is to do it manually through php scripts
update the column with an SQL statement in the AfterInsert event of the form
global $DBConnection; //change this to your DB Connection
$maxid = CCDLookUp("max(id)","table","",$DBConnection); //not the best approach though
$db = new clsDBConnection(); //change this to your DB Connection
$SQL = "update table set filename='/mydirname/'.filename where id=".$maxid;
$db->query($SQL);
$db->close();
hope this helps... all the best!
pal,
Benjohn
_________________
~=~=~=~=~=~=~=~=~=~=~=
get it done. make it happen.
~=~=~=~=~=~=~=~=~=~=~= |
|
|
Gena
Posts: 591
|
Posted: 10/14/2011, 7:47 AM |
|
Quote benjohn:
hi there Gena,
another approach is to do it manually through php scripts
update the column with an SQL statement in the AfterInsert event of the form
global $DBConnection; //change this to your DB Connection
$maxid = CCDLookUp("max(id)","table","",$DBConnection); //not the best approach though
$db = new clsDBConnection(); //change this to your DB Connection
$SQL = "update table set filename='/mydirname/'.filename where id=".$maxid;
$db->query($SQL);
$db->close();
hope this helps... all the best!
pal,
Benjohn
As I wrote above UploadFile component will confuse about this modification and you get error File you use in ... not found!
_________________
Gena |
|
|