<?php include('globalvariables.php'); ?><?php// make sure the image-data exists and is not empty// xampp is particularly sensitive to empty image-dataif ( isset($_POST["image"]) && !empty($_POST["image"]) ) {define('UPLOAD_DIR', $_POST["uploadDir"]);// get the dataURL$dataURL = $_POST["image"];// the dataURL has a prefix (mimetype+datatype)// that we don't want, so strip that prefix off$parts = explode(',', $dataURL);$data = $parts[1];// Decode base64 data, resulting in an image$data = base64_decode($data);// create a temporary unique file name$file = $TOOLHOME . UPLOAD_DIR . $_POST["name"];// write the file to the upload directory$success = file_put_contents($file, $data);// return the temp file name (success)// or return an error message just to frustrate the user (kidding!)print $success ? $file : 'Unable to save this image.';}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。