hello again, well i have found a way to resolve the issue of having a form and trying to update <input type=file>. i use phptriad 2-2-1 for the moment, as its easier to install, and i find jpg uploads arent corrupted with apache 1 as they are with apache 2 for me 🙂 , anyway the problem is you have a form, and you want to enter say name,address,email and a picture etc into a mysql database. for the picture you could use a BLOB in mysql but i saved the paths and uploaded the picture to windows xp sp2. at this point i should mention im no expert with programming , ive not got past IF ELSE statements with PHP but it will come in time 😛. in my mysql db i have a table with an "id" that is auto incremented when a new entry is INSERTed into the db from a form. two of the fields in a row are "image_name" and "image_path" which contain "picture.gif"and "/path_to/picture.gif" respectively as examples. every time i alter any data from an "id" if i DO NOT browse to the picture again, before i submit it, i end up with a broken link to it. with me so far? it seems that we can`t ECHO the existing path and image name into the file input field.
if(add_pic) {
echo $myrow['year'];
$base_path = "c:/apache/htdocs/cookery/".$image_name;
chmod ($base_path, 0644);
copy($_FILES['image']['tmp_name'],$base_path);
$image_path = "/cookery/".$image_name;
}
so if there is no image_name, image_path = "/cookery/" and we can`t display the image. my way around this is to enter the image_path and image_name TWICE, but the 2nd set of COLUMNS are only updated if ($image_path!=="/cookery/")
if ($id) {
$sql = "UPDATE personal SET name='$name', address='$address', landline='$landline', mobile='$mobile', work='$work', email='$email', pic_name='$pic_name', image_path='$image_path', image_name='$image_name', web='$web', comments='$comments', password='$password', regged='$regged', admin_status='$admin_status' WHERE id=$id";
if ($image_path!=="/cookery/")
{
$sql2 = "UPDATE personal SET image_path_bak='$image_path', image_name_bak='$image_name' WHERE id=$id";
}
}
##########################
else { $sql = "INSERT INTO personal (name,address,landline,mobile,work,email,pic_name,image_path,image_name,web,comments,password,regged,admin_status) VALUES ('$name', '$address', '$landline', '$mobile', '$work', '$email', '$pic_name', '$image_path', '$image_name', '$web', '$comments', '$password', '$regged', '$admin_status')";
if ($image_path!=="/cookery/"){ $sql2 = "insert into personal (image_path_bak,image_name_bak) VALUES ('$image_path','$image_name')"; }
##########################
$result = mysql_query($sql);
$result2 = mysql_query($sql2);
so unless the picture is changed it remains the same even if any other form data is altered..
echo "<a href='$image_path_bak'.'image_name_bak'><img src='$image_path_bak'.'$image_name_bak' width=80 height=60 border=0 alt=ENLARGE></a>";
} else { echo ""; } ?><font class=text><-- click me to enlarge</font>
i fully expect more experienced users to have overcome this issue but for the newbies this can save you hair loss 🙂 dont mock my code im still a key bashing munkeh 😛. if anybody has better ideas please post.
hth
amiga_spide