PHP won’t post image data

Okay so I’m working on a program that takes canvas data, takes a screenshot, adds in in a text box, and posts it to htdocs/creations/random number.xml. It posts some subbmited data; but not the model tag.

The model tag gets the JSC3D (I know no one here has ever heard of that; that has nothing to do with the problem) data from the text box I talked about and adds it should add it as <model>image data</model>. But instead it outputs the model tag as </model>. No opening tag or data; just </model>.

Here’s my PHP code:

<?php
$errors = array();

if(isset($_POST['save'])){

    $canvas = $_POST['img_text'];

    $username = $_SESSION['username'];

    $model_id = rand(1, 10000);

    $model_name = $_POST['name'];

    $model_description = $_POST['description'];

    if(file_exists('../creations/' . $model_id . '.xml')){
        $errors[] = 'Random model ID already exists. Please try saving again';
        }

    if($model_name == '') {
        $errors[] = 'Model name is blank';
    }

    if($model_description == ''){
        $errors[] = 'Description is blank';
        }

        if(count($errors) == 0){
            $xml = new SimpleXMLElement ('<creation></creation>');

            $xml->addChild('model', $canvas);

            $xml->addChild('id', $model_id);

            $xml->addChild('name', $model_name);

            $xml->addChild('description', $model_description);

            $xml->asXml('../creations/' . $model_id . '.xml');

            header('Location: index.php');
        }
            
}
?>
<!DOCTYPE HTML">
<HTML>
 <HEAD>
  <TITLE> JSC3D - test </TITLE>
  <!--[if lt IE 9]><script type="text/javascript" src="js/flashcanvas.js"></script><![endif]-->
  <link rel="stylesheet" type="text/css" href="style.css">
 </HEAD>

 <BODY onload="init()">

     <div class="action_buttons">
        <b>Actions:</b>
        <input type="button" value="File" onClick="alert('Error loading save menu')" />
        <input type="button" value="Help" onClick="alert('Error loading help menu')" />
        <input type="button" value="Rotate down" onClick="viewer.rotate(-10,0,0);viewer.update();" />
        <input type="button" value="Rotate up" onClick="viewer.rotate(10,0,0);viewer.update();" />
        <input type="button" value="Rotate left" onClick="viewer.rotate(0,-10,0);viewer.update();" />
        <input type="button" value="Rotate right" onClick="viewer.rotate(10,0,0);viewer.update();" />
        <input type="button" value="Zoom in" onClick="viewer.zoom(0,10,0);viewer.update();" />
        <input type="button" value="Zoom out" onClick="viewer.zoom(0,-10,0);viewer.update();" />
        <input type="button" value="Reset viewer" onClick="viewer.resetScene();viewer.update();" />
     </div>

    <div class="mode_buttons">
        <b>Mode:</b>
        <input type="radio" name="operate" value="rotate" onclick="viewer.setMouseUsage('rotate');" checked="true">Rotate
        <input type="radio" name="operate" value="zoom" onclick="viewer.setMouseUsage('zoom');">Zoom
        <input type="radio" name="operate" value="pan" onclick="viewer.setMouseUsage('pan');">Pan
    </div>
    
    <div class="blocks">
        <b>Scene:</b>
        <select id="model_list">
        <option>base.stl</option>
        <option>jsc_logo.obj</option>
        <option>blocks.obj</option>
        <option>minifig.obj</option>
        </select>
        <input type="button" id="load" value="Load model" onClick="loadModel();" />
        <select id="render_mode_list">
        <option>render as flat</option>
        <option>render as smooth</option>
        <option>render as wireframe</option>
        <option>render as points</option>
        <option>render with environment</option>
        </select>
        <input type="button" id="change" value="Change render mode" onClick="setRenderMode();" />
     </div>

     <form method="post" action="">
            <?php
            if(count($errors) > 0) {
                echo '<ul>';
                foreach($errors as $e){
                    echo '<li>' . $e . '</li>';
                }
                echo '<ul>';
            }
            ?>

            <br/>

            <div class="save">

                <b>Save:</b>
                <input type="text" value="Name" name="name" />
                <input type="text" value="Description" name="description" />
                <br />
                <input type="submit" value="Save model" name="save" />

                <div class="screenshot"><input type="button" id="screenshot" value="Take screenshot" onClick="takeScreenshot();" /></div>
                <br /><center><div id="sc"></div></center>

            </div>
        </form>

    <div id="canvas-head" style="width:640px; margin:auto; position:relative; font-size: 9pt; color: #777777;">
        <canvas id="cv" style="border: 1px solid;" width="640px" height="480px" ></canvas>
    <div>
        
     <canvas id="tex" style="border:1px solid;" width="1" height="1"></canvas>
    </div>
    
    */ ie or not /*
    <!--[if !IE]><!-->
     <script type="text/javascript" src="jsc3d.js"></script>
     <script type="text/javascript" src="jquery.js"></script>
    <!--<![endif]-->
    <!--[if IE]>
     <script type="text/javascript" src="ie.js"></script>
     <script type="text/javascript">
      JSC3D.Texture.cv = document.getElementById('tex');
     </script>
    <![endif]-->
    <script>
    */ JS3CD stuffz /*

   
   function takeScreenshot() {
        var canvas = document.getElementById("cv");
        var imgData    = canvas.toDataURL("image/png");
        document.getElementById("sc").innerHTML += '<img src="'+imgData+'" id="image">';
        $(image).width(240);

        document.getElementById("sc").innerHTML += '<input type="text" value="'+imgData+'" id="img_text">';
        $(image).width(240);
        
    }

  </script>
 </BODY>
</HTML>

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật