if(isset($_POST['uploadpixelURL'])){ $newname = $_SESSION[userid].'_'.md5(rand(1,1000)).'.gif'; $target_path = $target_path . $newname; echo "The file: ". basename( $_FILES['uploadpixelURL']['tmp_name'])." has been uploaded"; if(move_uploaded_file($_FILES['uploadpixelURL']['tmp_name'], $target_path)) { // i cant get this line to be true chmod($target_path,0777); } else{ echo "

There was an error uploading the file, please try again

"; } }else{ ... }