Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Renaming files on server as uploading

Status
Not open for further replies.

purcion

Programmer
Feb 14, 2005
32
AU
Im having some problems in my code below , the file uploads no problem , the string replace only works on the data written to the tblZ_Img , but not the actual image being uploaded.
example:
original file name on my hd name is
Te sst.jpg
I use the script below to upload it
its name is written into the db table as
Te**sst.jpg
but is still uploaded into the servers directory as
Te sst.jpg
Rather than helping my cause it makes it worse because the entry on the db is different to the actual file so its now a broken link. I mean all i wanted to do really was to strip the white space from the images name when uploading ..
I thought this would work ,can someone please modify the code below so it does what I want it to . much appreciated.
Thanks

Code:
$file_image = $HTTP_POST_FILES['file_image']['name'];       
$file_image = str_replace(" ","*",$file_image);
   
   
$date = date("j F Y");
$add =MYSQL_QUERY("INSERT INTO tblZ_Img (id,title,date,image,name,description,file_image)". "VALUES 
('NULL', '$title', '$date', '$image','$name','$description','$file_image')");
//success...

      
copy($HTTP_POST_FILES['file_image']['tmp_name'],"images/".$HTTP_POST_FILES['file_image']['name']);
unlink($HTTP_POST_FILES['file_image']['tmp_name']);
     
     
      
     
echo("Description Added!");
?>
 
Or actually use something like

$file_image = str_replace(" ","",$file_image);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top