i am using the ck editor and i wrote this code for insert image in mysql but this code doesn’t insert name file in feild’s path just it insert folder’s name i don’t where’s problem?
i appreciate everyone help me
$uploadDir = 'upload/';
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$filePath = $uploadDir . $fileName;
$ext = explode(".", $_FILES['userfile']['name']);
$ext = $ext[ count($ext) - 1 ];
$mime = $_FILES['userfile']['type'];
$valid_ext = array("jpg", "jpeg", "gif", "png", "bmp");
if(in_array($ext, $valid_ext)){
$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
//echo'<font color="#FF0000">Error uploading file</font>';
}}
else{
$select='<font color="#FF0000"><br/>لطفا یک فایل از نوع (jpg ,jpeg ,gif ,png ,bmp) انتخاب کنید</font>';
}
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
$ext = explode(".", $_FILES['userfile']['name']);
$ext = $ext[ count($ext) - 1 ];
$mime = $_FILES['userfile']['type'];
$valid_mime = $valid_mime_image;
$valid_ext = array("jpg", "jpeg", "gif", "png", "bmp");
$sw=mysql_query("INSERT INTO message (text1,title,date,visits,path) VALUES('".$editortext."','".$tit."','".jmaketime()."','0','".$filePath."') ");
mysql_query('SET names utf8') or die(mysql_error());