jonnyfive333
06-19-2004, 08:15 PM
i'm working on a site that needs pictures to be uploaded to a site but the picture needs to be renamed be fore it is placed in the database PLEASE HELP:spam::homer::stan::beer:
![]() | View Full Version : picture upload to db with rename jonnyfive333 06-19-2004, 08:15 PM i'm working on a site that needs pictures to be uploaded to a site but the picture needs to be renamed be fore it is placed in the database PLEASE HELP:spam::homer::stan::beer: xelav 06-20-2004, 01:34 AM but what problem do you have exactly? when you uploading, you can name picture as you want look at move_uploaded_file() function azizny 06-20-2004, 10:42 AM Easy.... //get the file name from post $filename = $_FILES['file1']['name']; //get the extension be explode $get_ext = explode(".",$filename); //make the name for the new file $new_name = 'This_is_the_new_name' . $get_ext[1]; //make the actual location for file $filelocation = 'images/' . $new_name; //actually upload file move_uploaded_file($_FILES[''file1'']['tmp_name'],$filelocation ); //Insert into database $insert_checker = @mysql_query("INSERT INTO files `filename`='filename',`locationi`='$filelocation',`ext`='$get_ext[1]'"); //check if inserted into database if($insert_cehcker){ echo file uploaded; } else { echo file not uploaded' } Peace, jonnyfive333 06-20-2004, 11:54 AM i'm using asp with access do you happen to have that or know where i can get it ACW 06-20-2004, 12:25 PM Note that you do not need to literally rename the file if you are going to store it in a database. The file goes in 1 field and the name you want to call it goes on another. A quick search in google pointed me to this code that does not require a 3rd party component to upload in ASP. http://www.asp101.com/articles/jacob/scriptupload.asp Let us know how it goes. jonnyfive333 06-21-2004, 11:05 PM i what the file renamed how do i go about that. |