Special characters
Posted: Sat Jun 09, 2007 1:16 pm
Well, first of all I am working on a project and this site is in spanish so I need to use these characters: áéíóúñ.
So my problem is: I have an 'uploading file' section where I upload files with this format: Author - Title of the file.doc.
I use explode(" - ", $string) to split the file name into pieces and save it in a db. That's working fine so far but when I upload files and its name contains any special characters, the file doesn't get saved with the original name+special characters in the server. It does in the db. (Eew, I hope you guys understand this part).
I'll paste my file.php class here:
So what I want is, save the files in the server with the original name+special characters. And save it in db with special characters too. And when I want to display this information, display them with special charactes too lol 
I know most of you won't understand this because you're main language is english. But any help is welcomed.
So my problem is: I have an 'uploading file' section where I upload files with this format: Author - Title of the file.doc.
I use explode(" - ", $string) to split the file name into pieces and save it in a db. That's working fine so far but when I upload files and its name contains any special characters, the file doesn't get saved with the original name+special characters in the server. It does in the db. (Eew, I hope you guys understand this part).
I'll paste my file.php class here:
Code: Select all
<?php
/* file.php */
Class File
{
/* MEMBER DATA */
private $db;
/* CONSTRUCTOR */
public function File($db)
{
$this->db= $db;
}
/* BEHAVIORS */
public function UploadFile()
{
if (isset($_POST['upload']))
{
$extension= explode(".", $_FILES['file']['name']);
if ($extension[1] != "doc")
{
die ("La extension del archivo no es valida.");
}
else
{
$path= "files/";
$path= $path. basename($_FILES['file']['name']);
if (move_uploaded_file($_FILES['file']['tmp_name'],$path))
{
$author= explode(" - ",$_FILES['file']['name']);
$title= explode(".",$author[1]);
$title2= explode(".",$title);
$date= time();
$sql= "INSERT INTO archivos (author, title, type, date) VALUES (%s, %s, %s, %d)";
$vars= array($author[0],$title[0],$_POST['type'],$date);
$result= $this->db->query($sql, $vars) or die ("ERROR");
die ("El archivo ha sido guardado exitosamente.");
}
else
{
die ("Ha habido un error al subir el archivo. Intente mas tarde.");
}
}
}
}
}
?>I know most of you won't understand this because you're main language is english. But any help is welcomed.