roll_or_die Posted May 29, 2007 Share Posted May 29, 2007 I was told to use the chmod function to allow my script permission to write the file to the server, here is the script I have at the moment: <?phpinclude "conn.php"; //rename file $res=(mysql_query("SELECT num FROM num")); $num=mysql_result($res, 0); $num++; $target=$target.$num.'.jpg'; chmod($target, 0777); $res=mysql_query("UPDATE num SET num = $num"); //check dimensions and filetype, 200px and jpg $tmpname=$_FILES['file']['tmp_name']; $size=getimagesize($tmpname); $filetype=$size[2]; if($filetype!=2) { echo "<b>ERROR: All images must be a .jpg</b>"; } //transfer file and insert into databases elseif(move_uploaded_file($_FILES['file']['tmp_name'], $target)) { $name=$num; //mysql_query("INSERT INTO pics(name) VALUES('$name')"); $select=$_POST['select']; $pic=$_POST['pic']; $res=mysql_query("UPDATE gallery SET $pic='$name' WHERE name = '$select'"); if(!$res) { echo '<p>'.mysql_error(); } echo 'Image '.$name.'.jpg uploaded to '.$select.' '.$pic; } else { echo 'error'; } ?> But what happens now, is that instead of receiving the error message in the else statement, i receive the other message [as if it was a success]. but it doesnt name the file, insert anything into the database or even transfer the file. here is the message I am presented with: Image .jpg uploaded to Gallery1 pic1Does anyone know how i can fix it?Thanks. Link to comment Share on other sites More sharing options...
vijay Posted May 29, 2007 Share Posted May 29, 2007 Hi...before chmod first check whatever filename come into $targetthat is exist on server or not..?if yes then go 4 the next step..and debug ur code line by line i.e check and dump $size array what u r getting..?Regards,Vijay Link to comment Share on other sites More sharing options...
justsomeguy Posted May 29, 2007 Share Posted May 29, 2007 You also never set the $target variable. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.