I have three files:
1. moodsLogo.jpg
2. Copy of (images').jpg
3. Moods logo (Custom).jpg
and I have the following code:
// (..) some code here
$fileName = valid_filename($_FILES[ 'Filedata' ][ 'name' ]);
$bl->updateFieldValue("tableName","columnName",$fileName, $id);
function valid_filename($filename)
{
$filename = str_replace(" ", "_", $filename);
$pattern = "/[^[a-z0-9._-]/";
return preg_replace($pattern, "", strtolower($filename));
}
And the SQL looks like this:
public function updateFieldValue($table,$column,$value, $id)
{
$result = parent::updateRow($table,$column, $value, $id);
return $result;
}
public function updateRow($table,$column, $value, $id)
{
$sql = "UPDATE $table SET $column = '$value' WHERE id = $id";
$this->query($sql);
return $this->query_result;
}
Now, processing file 1 and 2 works fine. In my DB I can see the entire filename with the extension.
But when I process file 3, the filename is either stored as moods_logo_custom.jp
or moods_logo_custom.
. I've even tried using 'Copy of (Custom).jpg
' and it works fine.
An echo before calling the query, shows that $filename is correct.
So what on earth makes THAT specific filename fale ? Why can't I store the entire filename in DB?