jasonp
|
| Posted: 04/13/2005, 3:57 PM |
|
Hi
I wish to upload a file but then insert a database record and use the "insert id" in the final file where to save it to. Also there is a 2nd ID that is used for a member and that is a directroy for example.
sourefile: demo.jpg
I have a struture like.
"images/[userid]/[lastid].jpg"
So if user 5 logs in and there are 100 records allready the next record id will be 101 I should have.
"image/5/101.jpg"
So I must save the upload file "demo.jpg" to "image/5/101.jpg"
Thanks.
|
|
|
 |
hidran
Posts: 29
|
| Posted: 04/20/2005, 9:08 AM |
|
In after insert you can make a query like :
global $DBconnection;
$sql= "select count(*) as tot from table where userid=".CCGetUserID();
$DBconnection->query($sql);
$DBconnection->next_record();
$file_id=$DBconnection->f("tot");
then in after process file you can use the rename function.
$old_name=$form_name->file_name->getValue()
rename("folder/".$old_name,"folder/".$file_id.".jpg");
of course, you should also rename the file name in the table
|
 |
 |
|