CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 File upload / rename

Print topic Send  topic

Author Message
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
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.