i have uploaded a pic in folder i want to store its path in the db whts code line can help me for this
you have line of code like this
[php]
(move_uploaded_file($_FILES[“userFile”][“tmp_name”],“upload/”.$finaleName))
[/php]
all you need to do is run a query to insert the path.
[PHP]
$SQL = “INSERT INTO table (filename,filepath) VALUES (’.$_FILES[‘userFile’][‘name’].’,'upload/”.$digest_name."’)"
[/PHP]
whts means file path absolute path or relative path ???
whts datatype should i select to store this path ???
it just the field name i put on my database you can change to whatever you want
can we store just the path without file name then how to retrieve this image on website from path stored in db
sure. you can either show me the codes you have so i can help you.
or
I can help you thru teamviewer.
ok dear its our night time we ll discuss t in morningg
anybody there
I thought you were going to sleep
i gotup right now
cool, so what is it that you need help with?
you starting from scratch or you have codes? if so please post your codes so that i can help you
[php] public function uploadPic(){
$upload_errors = array(
UPLOAD_ERR_OK => "No errors.",
UPLOAD_ERR_INI_SIZE => "Larger than upload_max_filesize.",
UPLOAD_ERR_FORM_SIZE => "Larger than form MAX_FILE_SIZE.",
UPLOAD_ERR_PARTIAL => "Partial upload.",
UPLOAD_ERR_NO_FILE => "No file.",
UPLOAD_ERR_NO_TMP_DIR => "No temporary directory.",
UPLOAD_ERR_CANT_WRITE => "Can't write to disk.",
UPLOAD_ERR_EXTENSION => "File upload stopped by extension."
);
$all_ext=array('jpg','png','jpeg','gif');
if(isset($_FILES['std_pic'])){
$img=$_FILES['std_pic'];
$file=$_FILES['std_pic']['name'];
$a=explode('.',$file);
$file_ext= end($a);
$file_size=$_FILES['std_pic']['size'];
$file_temp=$_FILES['std_pic']['tmp_name'];
$upload_dir="uploads";
if(!in_array($file_ext,$all_ext)){
$this->error_message[]="Extension not Allowed";
}
if(!move_uploaded_file($file_temp,$upload_dir."/".$file)){
$error = $_FILES['std_pic']['error'];
$this->error_message[]= $upload_errors[$error];
}
}
}[/php]
i have uploaded the file and i have stored it in a directory now i want to store it in db Whts data type should i use in db to store the path of this image. i want to store the path of the image in db and then how to retrieve it which query i need to use
Whts data type should i use in db to store the path of this image.the path is plain text, so you can use varchar or text as data type.
did you create the database or the table which will be used to store the path?
this pic is the part of a student admission form and the form data ll store in db along with this image path in some field
I have solved the problem thnks for all efforts