fejl ved update
hej, når jeg opdatere, får jeg den her fejl, "Din fil skal være i enten GIF, JPG eller BMP format og fylder mindre en 100kb (1024000 bytes)!" og det er ikke filen, der overskrider begrænsningen, hele koden er taget fra min upload formular, og så har jeg ændret på sql koden, fra insert into, til update, det er det eneste jeg har gjord, hvad gør jeg forkert ?<?php
ob_start();
require_once"../includes/dbConnect.php";
include "funktions.php";
if(isset($_POST['ok'])){
$nid = mysql_real_escape_string($_POST['nid']);
$ovs = mysql_real_escape_string($_POST['ovs']);
$txt = mysql_real_escape_string($_POST['txt']);
$menu = mysql_real_escape_string($_POST['menu']);
mysqli_query($conn,"UPDATE news SET NHead='".$ovs."', NBody='".$txt."', pmenu='".$menu."' WHERE NID=".$nid."");
//-------------------
//Filens midlertidige placering
$file=$_FILES['fil']['tmp_name'];
//Laver alle mellemrum om til underscore i fil navnet
$name=$_FILES['fil']['name'];
$name=str_replace(" ", '_', $name);
//Filens endelse
$ext=strrchr($_FILES['fil']['name'],'.');
$ext=strtolower($ext);
//Filtyper
$types=array(".gif", ".jpg", ".bmp");
//Destination
$path=$_SERVER['DOCUMENT_ROOT']."/cmsdbpic/upload/original/" . time() . "_". $name;
//joint timestamp and name
$newname = time() . "_". $name;
//tjekker om filypen er tilladt
if(in_array($ext, $types) && $_FILES['fil']['size'] < 1024000)
{
//hvad er det ?
move_uploaded_file($file, $path);
chmod($path, 0644);
//header("location: index.php");
$filname = $newname;
}
else
{ //print a fail messsages, if file not submit to rules
echo "Din fil skal være i enten GIF, JPG eller BMP format og fylder mindre en 100kb (1024000 bytes)!";
}
//select all from the table, thats equales to the variable ovs.
$query_ovs = mysqli_query($conn, "SELECT * FROM news WHERE NHead='".$ovs."'");
while($indsaet1 = mysqli_fetch_array($query_ovs)){
//insert filename and artikel id
$pid = $_GET['id'];
mysqli_query($conn,"UPDATE pic SET Pname='".$filname."' WHERE Pid=".$pid."");
}
//her begynder thumbnail
$org_img = "../upload/original/".$filname.""; //path of the images file
$org_img_new = "../upload/show/".$filname.""; //path of the thumbnail
$img = open_image($org_img); //open the images
#check if the file has been open
if ($img === false){
#image can not be open
echo "File is not a valid image";
}else{
#Original file size
$width = imagesx($img);
$height = imagesy($img);
if($width > $height){
#new file size
$width_new = 900;
$height_new = $height * ($width_new / $width);
}else{
$width_new = 600;
$height_new = $height * (width_new / $width);
};
#Resize / resample the image
$image_resized = imagecreatetruecolor($width_new, $height_new);
imagecopyresampled($image_resized, $img, 0, 0, 0, 0, $width_new, $height_new, $width, $height);
#Check if the images have been resized
if (!isset($image_resized)){
$image_resized = $img;
};
#save the image
imagejpeg($image_resized, $org_img_new, 100);
####
cropImage(100, 65, '../upload/original/'.$filname.'','jpg','../upload/show/'.$filname.'');
####
echo "file is uploaded";
//indsæt ob_start(); i starten af script og slut med Ob_end_flush(); og put saa header location ind i mellem.
header ('location:index.php');
Ob_end_flush();
};
};
$id = $_GET ['id'];
$query = mysqli_query($conn,"SELECT * FROM news WHERE NID=".$id."");
$result = mysqli_fetch_array($query);
?>
<body>
<form method="post" action="edit.php" name="opret">
<input type="hidden" name="nid" value="<?php echo $result['NID']?>" />
<fieldset>
<legend> opret her </legend>
<table>
<tr>
<td>Overskrift:</td><td><input type="text" name="ovs" value="<?php echo $result['NHead']; ?>" /></td>
</tr>
<tr>
<td>Indhold:</td><td><textarea name="txt" style="width:200px;height:200px;">
<?php echo $result['NBody']; ?>