so, this is really hard to phrase, but I'm trying to use jQuery to move the file of an input element to a php file to put it into a message.
here's the code
HTML:
<form name="message" action="">
<input name="usermsg" type="text" id="usermsg"/>
<input name="userimg" type="file" id="userimg" accept="image/*"/>
<input name="submitmsg" type="submit" id="submitmsg" value="Send"/>
</form>
jQuery:
$(document).ready(function () {
$("#submitmsg").click(function () {
var clientmsg = $("#usermsg").val();
var clientimg = $("#userimg").val();
$.post("post.php", { text: clientmsg, img: clientimg });
$("#usermsg").val("");
return false;
});
//other stuff here
});
PHP:
$text = $_POST['text'];
$img = $_POST['img'];
$text_message = "<div class='msgln'><span class='chat-time'>".date("m-d, g:i A")."</span> <b class='user-name'>".$_SESSION['name']."</b> ".stripslashes(htmlspecialchars(preg_replace('/\pM/u', '', $text)))."<br><br>".$img."</div><!--". $_SESSION['ipAddr'] ."-->
";
file_put_contents('log.html', $text_message, FILE_APPEND | LOCK_EX);
If I add no file, it posts the message as usual (username and text), but if I add a file it says C:\fakepath\[file name and extension] note: fakepath is not a filler -- that's actually what it returns.