473,388 Members | 1,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

How to rename file name in DB

how to rename file name in DB..???

this my code, but this code only save image to folder, can't rename file in DB :

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. //Сheck that we have a file
  4. $folder = "../property/$spid";
  5. if(!file_exists($folder))
  6. {
  7.    mkdir($folder);
  8. }
  9. $sql = "UPDATE `$table` SET str_image1='$simage1' WHERE int_prop_ID='$spid'";
  10. }
  11.             if(mysql_query($sql, $conn) == false)
  12.                   {
  13.                     exit(mysql_error());
  14.                   }
  15.               else
  16.                 {
  17.                     $property_id = mysql_insert_id();
  18.                 }
  19.  
  20.         // Process image
  21.             for($i = 0; $i < count($_FILES["file"]["name"]); $i++)
  22.                 {
  23.                  // Update row
  24.                     $filename = $_FILES["file"]["name"][$i];        
  25.                     $sql = "UPDATE properties ".
  26.                               "SET str_image". ($i + 1) ."= '$filename' ".
  27.                               "WHERE int_prop_ID = $property_id ";
  28.                     mysql_query($sql, $conn);        
  29.  
  30.                 // Move file
  31.                 $tmp_filename = $_FILES["file"]["tmp_name"][$i];
  32.                 move_uploaded_file($tmp_filename, $folder ."/". $filename);
  33.                }
  34.  
  35. header( 'Location: view.php' );
  36.  
  37. ?>
  38.  
Jun 12 '07 #1
0 1377

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Venkat | last post by:
Hi All, Currently i guess rename and remove are not supported using fstream. How do i rename or remove a file? regards, Venkat
16
by: dudufigueiredo | last post by:
I have one folder containing mp3 files, the folder is: C:\My Shared Folder\Rubber Soul And the files are: 01 drive my car.mp3 02 norwegian wood.mp3 03 you won't see me.mp3 04 nowhere man.mp3...
5
by: jez123456 | last post by:
Hi, I’ve written a c# program to compact certain msaccess databases. The way this works is to compact say C:\test1.mdb to C:\temp.mdb, then delete C:\test1.mdb and rename C:\temp.mdb as...
1
by: Jay at SCA | last post by:
I've been having the following issue with a windows service I've created in vb.net (.net fw 1.1): Basically, my service monitors a folder for the creation of any new files of a particular type...
5
by: VB Programmer | last post by:
My web hoster says that I have to rename my ASPNETDB.MDF SqlExpress db for my 2.0 site to work. Is this accurate? If so, how can I rename it without breaking anything on my site? FYI: This is...
12
by: mantrid | last post by:
Im trying to move a file but am having luck my code is below. The temp and target paths are valid as they echo correctly. but I cant get the copy() function to work, or the rename() function ...
1
by: jonathan184 | last post by:
trying to rename filenames and extensions then add a header in line1 of each file if the header existed in line 1 to go to the next file. but i am getting error explciti errors Here is my...
3
by: rn5a | last post by:
An inquisitive question...... A ListBox lists all the directories & files residing in a directory on the server. Assume that the ListBox lists 2 directories & 4 files. Also assume that one of...
8
by: jack | last post by:
Hi, I have more than 1000 photos in my system but with very untidy name. Im trying to create a program through which i can rename the file. I have seen the examples on net an forums, but the...
1
by: achotto | last post by:
hi, i try to upload a multiple image files. after that i will rename the files name. the problem is when i upload a 2 or more same files name exp-goal.jpg, it will return "files already exist". ok...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.