Hello i have a problem. Locally (xampp local server) the image uploads just fine but it doesn't when i try it on my webiste. The GD library is activated. So thats not the issue.
html
<video id="player" width="480px" height="240px" autoplay></video> <button id="takeSnap" class="startbutton messageButton" style="display:none;">Take Snap</button> <div id="webcam"> <input type="hidden" id="uploadvalues"> <input type="hidden" id="upload_uid" value="<?php echo $sessionUid;?>" name="update_uid"> <input type="hidden" id="upload_token" value="<?php echo $sessionToken;?>" name="update_token"> <input type="hidden" id="group_id" value="<?php echo $groupID; ?>" name="group_id"> <canvas id="snapshot"></canvas> <div id="webcam_preview" style="display:none"></div>Inline Code Example Here
Javascript
captureButton.addEventListener('click', function() {
var context = snapshot.getContext('2d');
// Draw the video frame to the canvas.
context.drawImage(player, 0, 0, snapshotCanvas.width,
snapshotCanvas.height);
//start webcam upload
var webcamURL=apiBaseUrl+'api/webcamImageCreate';
var canvas = document.getElementById('snapshot');
$.post(webcamURL, {uid:uid, token:token,group_id:groupID, type: "data", image: canvas.toDataURL("image/png")},
function(data)
{
if(data)
{
var values=$("#uploadvalues").val();
$("#webcam_preview").prepend(data);
var X=$('.webcam_preview').attr('id');
if($.trim(values).length>0)
{
var Z= X+','+values;
}
else
{
var Z= X;
}
if(Z!='undefined,')
{
$("#uploadvalues").val(Z);
}
document.getElementById("noDisplayTakeSnap").style.display="block";
var canvas = document.getElementById('snapshot');
var context = canvas.getContext('2d');
context.clear();
}
PHP (webcamImageCreate)
function webcamImageCreate()
{
$request = \Slim\Slim::getInstance()->request();
$x = $request->post();
$uid=$_POST['uid'];
$token=$_POST['token'];
$group_id=$_POST['group_id'];
try
{
$key=md5(SITE_KEY.$uid);
if($key==$token)
{
$invalid = "iVBORw0KGgoAAAANSUhEUgAAAUAAAADwCAYAAABxLb1rAAAG+UlEQVR4Xu3UgREAIAgDMdl/aPFc48MGTbnOfXccAQIEggJjAIOti0yAwBcwgB6BAIGsgAHMVi84AQIG0A8QIJAVMIDZ6gUnQMAA+gECBLICBjBbveAECBhAP0CAQFbAAGarF5w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6gUnQMAA+gECBLICBjBbveAECBhAP0CAQFbAAGarF5wAAQPoBwgQyAoYwGz1ghMgYAD9AAECWQEDmK1ecAIEDKAfIEAgK2AAs9ULToDAAoCVvV4Lh4uLAAAAAElFTkSuQmCC";
**echo $_POST['image']; exit;** i tried that to see if it returns the $_POST. IT DOES!!!
if ($_POST['type'] == "pixel")
{
$image = $_POST['image'];
$filter_image = str_replace("data:image/png;base64,", "", $image);
// input is in format 1,2,3...|1,2,3...|...
if($filter_image == $invalid)
{
$im = "";
echo "false";
}
else
{
$im = imagecreatetruecolor(320, 240);
foreach (explode("|", $_POST['image']) as $y => $csv) {
foreach (explode(";", $csv) as $x => $color) {
imagesetpixel($im, $x, $y, $color);
}
}
}
}
else {
// input is in format: data:image/png;base64,...
$image = $_POST['image'];
$filter_image = str_replace("data:image/png;base64,", "", $image);
if($filter_image == $invalid)
{
$im = "";
echo "false";
}
else
$im = imagecreatefromjpeg($_POST['image']);
}
if($im)
{
$filename=time().$uid.".jpg";
if(empty($conversationImage))
{
$conversationImage='';
}
internalImageUpload($uid,$filename,$group_id,$conversationImage);
//imagejpeg($im);
$upload_path='../'.UPLOAD_PATH;
imagejpeg($im, $upload_path.$filename);
$imageID=internalGetUploadImage($uid,$filename);
$fullImagePath=BASE_URL.UPLOAD_PATH.$filename;
//echo '{"webcam": [{"imageName":"'.$fullImagePath.'", "imageID":"'.$imageID[0]->id.'" }]}';
imagedestroy($im);
echo "<img src='".$fullImagePath."' class='webcam_preview' id='".$imageID[0]->id."'/>";
}
}
}