KkillgasmM Posted May 29, 2007 Share Posted May 29, 2007 This is driving me crazy! everywhere I seem to look i cant seem to find a straight answer! Im using the following script to upload images into an image gallery: include "conn.php"; //rename file $sql=mysql_query("SELECT num FROM num"); if(!$sql) { echo mysql_error(); } else { $num=mysql_result($sql, 0, 0); echo 'num is '.$num.'<p>'; $num++; } $target="Images/pics/"; $target=$target.$num.'.jpg'; $target=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; $select=$_POST['select']; $pic=$_POST['pic']; $res=mysql_query("UPDATE gallery SET $pic='$name' WHERE name = '$select'"); if(!$res) { echo '<p>'.mysql_error(); } echo mysql_affected_rows($res).'<p>Image '.$name.'.jpg uploaded to '.$select.' '.$pic; } else { echo 'error'; } But it comes up with the error in the else statement. Ive been told that its due to a permissions error, and to chmod the file [or directory?] My attempt at doing this was by inserting this into the script: $target="Images/pics/"; $target=$target.$num.'.jpg'; $target=chmod($target, 0777); But it still doesnt work! Please help me!! Thanks. Link to comment https://forums.phpfreaks.com/topic/53412-file-upload-problem/ Share on other sites More sharing options...
rhyspaterson Posted May 29, 2007 Share Posted May 29, 2007 have you tried chmod'ing the file/directory manually first to see if everything works? Link to comment https://forums.phpfreaks.com/topic/53412-file-upload-problem/#findComment-263893 Share on other sites More sharing options...
KkillgasmM Posted May 29, 2007 Author Share Posted May 29, 2007 Would that be using an FTP client? because i upload my files through dreamweaver Link to comment https://forums.phpfreaks.com/topic/53412-file-upload-problem/#findComment-263910 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.