JSFiddle - React, Tailwind, and code Playground
by dshilkret
HTML
><input id="getFile" type="file"/><br />
<input id="displayFileName" type="text" value="Enter a unique filename name" /><br />
<input id="addFileButton" type="button" value="Upload" onclick="uploadFile()"/>
<span>Div1</span>
<div id='div1'>
Test1
</div><br>
<span>Div2</span>
<div id='div2'>
Test2
</div>
<div id='div3'>
Test3
</div>
<script>
/********************************************************************
Copyright (c)) 2016 Randy Amiel ([email protected])
*********************************************************************
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
********************************************************************/
/*
Requires: jQuery
*/
jQuery(document).ready(function () {
// Check for FileReader API (HTML5) support.
if (!window.FileReader) {
alert('This browser does not support the FileReader API.');
}
});
// Upload the file.
// You can upload files up to 2 GB with the REST API.
function uploadFile() {
console.log("In UploadFile Method = true");
// Define the folder path for this example.
var serverRelativeUrlToFolder = '/shared%20documents';
// Get test values from the file input and text input page controls.
var fileInput = jQuery('#getFile');
var newName = jQuery('#displayName').val();
// Get the server URL.
var serverUrl = "https://sdev2.sharepoint.com";
// Initiate method calls using jQuery promises.
// Get the local file as an array buffer.
var getFile = getFileBuffer();
...