久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

嘗試使用輸入類型文本傳遞超過 524288 字節(jié)的 T

Trying to Pass ToDataURL with over 524288 bytes Using Input Type Text(嘗試使用輸入類型文本傳遞超過 524288 字節(jié)的 ToDataURL)
本文介紹了嘗試使用輸入類型文本傳遞超過 524288 字節(jié)的 ToDataURL的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試使用 Canvas 的 DataURL(使用 JavaScript)創(chuàng)建圖像.當用戶點擊提交時,該值會被發(fā)送到一個輸入類型的文本標簽(例如,),然而,顯然在 Chrome 上,當它的長度為 524,288 個字符.

我將它發(fā)送到輸入標簽,因為我需要在 PHP 中獲取值(作為 $_POST['dataurltext'];),以便我可以創(chuàng)建一個圖像并將其上傳到我的網(wǎng)絡服務器.

關于如何繞過這個長度的任何想法?

我應該改用評論框嗎?

感謝您的幫助,不勝感激.

解決方案

Try sent canvas as Blob at javascript;使用 fopen()php://input 作為參數(shù)來讀取 Blobstream_copy_to_streamfile_get_contents() , file_put_contents()php

處處理文件

參見 HTMLCanvasElement.toBlob()

if (!HTMLCanvasElement.prototype.toBlob) {Object.defineProperty(HTMLCanvasElement.prototype, 'toBlob', {價值:功能(回調(diào),類型,質(zhì)量){var binStr = atob( this.toDataURL(type, quality).split(',')[1] ),len = binStr.length,arr = new Uint8Array(len);for (var i=0; i

除了 $_POST, $_GET和 $_FILE:在 JavaScript 和 PHP 中使用 Blob

I am trying to create an image using DataURL of a Canvas (using JavaScript). When a user hits submit, the value gets sent to an Input type text tag (e.g., <input type='text'>), however, apparently on Chrome, the text gets cut off when it is at length 524,288 characters.

I am sending it to an input tag because I need to obtain the value in PHP (as a $_POST['dataurltext'];), so that I can create an image and upload it to my web server.

Any ideas on how to bypass this length?

Should I use a comment box instead, maybe?

Thank you for any help, it will be greatly appreciated.

解決方案

Try sending canvas as Blob at javascript; use fopen() with php://input as parameter to read Blob, stream_copy_to_stream or file_get_contents() , file_put_contents() to process file at php

See HTMLCanvasElement.toBlob()

if (!HTMLCanvasElement.prototype.toBlob) {
 Object.defineProperty(HTMLCanvasElement.prototype, 'toBlob', {
  value: function (callback, type, quality) {

    var binStr = atob( this.toDataURL(type, quality).split(',')[1] ),
        len = binStr.length,
        arr = new Uint8Array(len);

    for (var i=0; i<len; i++ ) {
     arr[i] = binStr.charCodeAt(i);
    }

    callback( new Blob( [arr], {type: type || 'image/png'} ) );
  }
 });
}

Beyond $_POST, $_GET and $_FILE: Working with Blob in JavaScript and PHP

<?php

// choose a filename
$filename = "hello.json";

// the Blob will be in the input stream, so we use php://input
$input = fopen('php://input', 'rb');
$file = fopen($filename, 'wb'); 

// Note: we don't need open and stream to stream, we could've used file_get_contents and file_put_contents
stream_copy_to_stream($input, $file);
fclose($input);
fclose($file);

?>

這篇關于嘗試使用輸入類型文本傳遞超過 524288 字節(jié)的 ToDataURL的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數(shù)組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產(chǎn)生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 99热在这里只有精品 | 亚洲一区中文字幕 | 91视频一区二区三区 | 精品一区二区视频 | 国产特黄一级 | 色一情一乱一伦一区二区三区 | 国产精品久久 | 亚洲欧美中文日韩在线v日本 | 拍真实国产伦偷精品 | 91精品导航| 色999视频 | 亚洲精品www.| 日韩欧美中文字幕在线观看 | 成人一级视频在线观看 | 亚洲精品1区 | 亚洲一区网站 | 日本久久精| 久久久国产精品入口麻豆 | 97人人澡人人爽91综合色 | 精品少妇一区二区三区在线播放 | 日韩在线一区二区三区 | 免费看国产一级特黄aaaa大片 | 免费观看日韩av | 亚洲精品1区 | 51ⅴ精品国产91久久久久久 | 久久精品视频在线观看 | 中文字幕视频一区 | 成人欧美一区二区三区黑人孕妇 | 一区二区免费在线视频 | av在线成人 | 国产精品久久久乱弄 | 久久久亚洲综合 | 91精品久久久久久久久中文字幕 | 国产乱码精品一区二区三区中文 | 一区二区三区小视频 | 偷拍自拍网址 | 亚洲深夜福利 | 国产成人精品午夜视频免费 | aaa国产大片 | www日韩高清| 在线视频一区二区三区 |