I have developed small application with small form,Name and image.
- When i am fill the form and click on submit button these form values are stored in database(Name and image path stored in database),and image stored in target folder.
- Here is a problem,when i am click on form edit button,edited Name its successfully edited and stored in database.
- But when i am browse a image file it's not storing his path into database and image into target folder.
It shows old image path and Image in DB and form.
Here is code. Form.html
<html>
<form name="files" onsubmit="return formValidator()" action="update.php" method="POST" enctype="multipart/form-data">
<label class="form_label_name">Name<span class="red">*</span>:</label>
<input name="name" type="text" maxlength="32" class="form_input_name" id="form_name" required value="<?php {echo $row['name'];} ?>">
<label class="form_label_image">Grid Image:</label>
<img id="imagetd" class="gridimage" src="<?php {echo $row['thumbnailimage'];} ?>" onclick="getImagePathFromDialog()" />
<label>Click on the image to change the Image</label>
<input type="file" id="imageBrowser" name="imageBrowser" onchange="readURL(this);" style="visibility:hidden;" />
<input type="submit" value="Save" name="submit" class="editfile_save">
</html>
Edit Form:-
update.php:-
<?php
global $nodeid;
global $parentnodeid;
global $user;
global $file_type;
$file_type=$_GET['type'];
$userid=$user->uid;
if(isset($_POST['submit']))
{
$dbhost = 'localhost';
$dbuser = 'xxx';
$dbpass = 'yyy';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
$sqlappidquery = "SELECT appid FROM app WHERE userid=$userid ";
$appidqueryrows = db_query($sqlappidquery, array());
foreach ($appidqueryrows as $appidrow) {
$app_id=$appidrow->appid;
}
if(! get_magic_quotes_gpc() )
{
$name = addslashes ($_POST['name']);
$summary = addslashes ($_POST['summary']);
$url= addslashes ($_POST['urlPath']);
}
else
{
$name = $_POST['name'];
$summary = $_POST['summary'];
$url = $_POST['urlPath'];
}
$target_path = "/sites/default/files/content_images/";
$imagepath=basename( $_FILES['imageBrowser']['name']);
$ext = explode("/", $_FILES['imageBrowser']['type']);
if($ext[0] == 'image')
{
if(empty($imagepath))
{
$target_path =$row['thumbnailimage'];
}
else
{
$target_path = $target_path . basename( $_FILES['imageBrowser']['name']);
}
move_uploaded_file($_FILES['imageBrowser']['tmp_name'], $target_path);
}
else
{
$target_path =$row['thumbnailimage'];
}
?>
Can any one help me on this problem.