I have tried several things to get my image data from the file input and send it to the NodeJS server but nothing has helped me so far. I had a lot of different solutions with formData, FileReader etc. but I never had my data.  My HTML is following:  &lt;button type="button" id="uploadButton" onclick="openFilepicker()"&gt; Upload file &lt;/button&gt;   The openFilepicker() function triggers a click via jQuery on the file-input element:  &lt;form id='uploadForm' encType="multipart/form-data"&gt;     &lt;input type="file" accept="image/*" name="uploader" class="hidden"      id="input-file" onchange="submitUploadForm()"/&gt; &lt;/form&gt;   The submitUploadForm() function gets executed when a file has been selected:  function submitUploadForm() {   if ($('#input-file').val() != '') {     const input = document.getElementById('input-file');     const file = input.files[0];      /* Process my data here to be ready to send it */      $.ajax({         url: '/upload',         type: 'POST',         data: '', /* Here I want my file data to be sent */         cache: false,         contentType: false,         processData: false,         success: function (data) {             console.log(data);         }.bind(this),         error: function (err) {             console.log(err);         }.bind(this)     });   } }
7478
I would like to upload a file asynchronously with jQuery.     $(document).ready(function () {     $("#uploadbutton").click(function () {         var filename = $("#file").val();          $.ajax({             type: "POST",             url: "addFile.do",             enctype: 'multipart/form-data',             data: {                 file: filename             },             success: function () {                 alert("Data Uploaded: ");             }         });     }); }); &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js"&gt;&lt;/script&gt; &lt;span&gt;File&lt;/span&gt; &lt;input type="file" id="file" name="file" size="10"/&gt; &lt;input id="uploadbutton" type="button" value="Upload"/&gt;     Instead of the file being uploaded, I am only getting the filename. What can I do to fix this problem?
25657
This is a canonical question, intended to provide a comprehensive answer to many related questions  During the course of a Webdriver test, I want to upload files. However, this opens a native file picker, which Webdriver doesn't seem to support interacting with. How do I interact with it?
26981
I searched all over this site and the web for a good and simple example of autocomplete using jQuery and ASP.NET. I wanted to expose the data used by autocomplete with a webservice (and will probably do that next). In the meantime, I got this working, but it seems a little hacky...  In my page I have a text box:  &lt;input id="txtSearch" type="text" /&gt;   I am using jQuery autocomplete, set up per their example:  &lt;link rel="stylesheet" href="js/jquery.autocomplete.css" type="text/css" /&gt; &lt;script type="text/javascript" src="js/jquery.bgiframe.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="js/jquery.dimensions.pack.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="js/jquery.autocomplete.js"&gt;&lt;/script&gt;   Here is where it starts to get hacky... I call a page instead of a webservice:    &lt;script type="text/javascript"&gt;     $(document).ready(function(){         $("#txtSearch").autocomplete('autocompletetagdata.aspx');     });         &lt;/script&gt;   In the page I stripped out ALL of the html and just have this (otherwise, various HTML bits show up in the autocomplete dropdown):  &lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="autocompletetagdata.aspx.cs" Inherits="autocompletetagdata" %&gt;   And in my autocompletetagdata.aspx, I am using SubSonic to query, format and return data from the database (one data item per line):  protected void Page_Load(object sender, EventArgs e) {     // Note the query strings passed by jquery autocomplete:     //QueryString: {q=a&amp;limit=150&amp;timestamp=1227198175320}      LookupTagCollection tags = Select.AllColumnsFrom&lt;LookupTag&gt;()         .Top(Request.QueryString["limit"])         .Where(LookupTag.Columns.TagDescription).Like(Request.QueryString["q"] + "%")         .OrderAsc(LookupTag.Columns.TagDescription)         .ExecuteAsCollection&lt;LookupTagCollection&gt;();      StringBuilder sb = new StringBuilder();      foreach (LookupTag tag in tags)     {         sb.Append(tag.TagDescription).Append("\n");     }      Response.Write(sb.ToString()); }   If you don't do a LIKE query, then it returns everything that contains a match for the character(s) you type -- e.g., typing "a" will include "Ask" and "Answer" as well as "March" and "Mega." I just wanted it to do a starts with match.  Anyway, it works and it's pretty easy to set up, but is there a better way?
112703
My goal is to get the login name and picture for the current user. I am using SharePoint 2013 Foundation. I tried three method and non of then worked correctly:   This is with jQuery SPServices:   function getCurrentUserInfo() {     var thisUsersValues = $().SPServices.SPGetCurrentUser({         fieldNames: ["ID", "Name", "Picture"],         debug: false     });      var name = thisUsersValues["Name"];      var ID = thisUsersValues["ID"];      var SIPAddress = thisUsersValues["Picture"];  }    But I am getting this error:     SCRIPT438: Object doesn't support property or method 'replace'      File: jquery.SPServices-2014.01.js, Line: 2414, Column: 17    REST API method:   function getinfo(loginName) {     var theData = {         "propertiesForUser": {             "__metadata": { "type": "SP.UserProfiles.UserProfilePropertiesForUser" },             "accountName": loginName,             "propertyNames": ["PreferredName", "PictureURL"]         }     };      var requestHeaders = {         "Accept": "application/json;odata=verbose",         "X-RequestDigest": jQuery("#__REQUESTDIGEST").val()     };      jQuery.ajax({         url: _spPageContextInfo.webAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertiesFor",         type: "POST",         data: JSON.stringify(theData),         contentType: "application/json;odata=verbose",         headers: requestHeaders,         success: function (data) {             document.getElementById("profilelink").href = userProfileProperties[1];;             document.getElementById("username").innerHTML = userProfileProperties[0];             if (userProfileProperties[1] !== null) {                 document.getElementById("Userprofileimage").src = userProfileProperties[1];             }         },         error: function (jqxr, errorCode, errorThrown) {             console.log(jqxr.responseText);         }     }); }    Error:     "{\"error\":{\"code\":\"-1,        Microsoft.SharePoint.Client.InvalidClientQueryException\",\"message\":{\"lang\":\"en-US\",\"value\":\"The method         GetUserProfilePropertiesFor cannot be invoked as its parameter propertiesForUser is not supported.\"},\"innererror\":        {\"message\":\"The method GetUserProfilePropertiesFor cannot be invoked as its parameter propertiesForUser is not supported.\"        ,\"type\":\"Microsoft.SharePoint.Client.InvalidClientQueryException\",\"stacktrace\":\"     With CSOM:  //SP.SOD.executeOrDelayUntilScriptLoaded(getUserProperties, 'SP.UserProfiles.js'); function getUserProperties(targetUser) {      // get the target users domain name and account name.     var tUser = targetUser.substring(7);     // Get the current client context.     var clientContext = new SP.ClientContext.get_current();     //Get PeopleManager Instance     var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);     // Get the properties to retrieve     var profilePropertyNames = ["PreferredName", "PictureURL"];     var userProfilePropertiesForUser = new SP.UserProfiles.UserProfilePropertiesForUser(         clientContext,         tUser,         profilePropertyNames);     // Get user profile properties for the target user     userProfileProperties = peopleManager.getUserProfilePropertiesFor(userProfilePropertiesForUser);     // Load the UserProfilePropertiesForUser object.     clientContext.load(userProfilePropertiesForUser);     //Execute the Query     clientContext.executeQueryAsync(onRequestSuccess, onRequestFail); }    I really don't understand where the issue is. Does anyone have an idea?
54650
Currently I had built a file upload functionality in Lightning component which accepts the CSV file, read it as text(Each row in CSV is split using \n and each column in the row is split using ,). Then each columns in each row are validated in Javascript and if everything is fine,the data is saved in the backend. While uploading the data, if the file contains , in its data then it is taken as another column. Eg: X-36936,SS-341487,11-WT,414081,"LENDERS, THE HACK",2-Manage,,,,,,,,,,,,12/1/2013,3150,,0,,Dealing,2018,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,  Here "LENDERS, THE HACK" is a single column but it is taken as 2 columns (LENDERS --> 1st column and THE HACK --> 2nd column).Could anyone please help me how to resolve this issue?
26428
I need to stream a file from Salesforce in our webapplication. To make sure the file is properly opened, I have to set Content-Type header.  How to retrieve the Content-Type (MIME) of a file?  I expect values like: image/png, application/pdf, text/html etc.  How to get these values? I am using the Java and a SOAP client to retrieve the data.
68158
Per , I've been working for about 2 weeks on trying to get Ajax uploading of files to work in Rails 3 using Paperclip to manage attachments. I finally found a solution that works really well, and is much better than any of the tips I got in several questions that I asked. In the spirit of sharing the final answer to all the questions I was asking I wanted to type up a &quot;canonical answer&quot; that would really explain how I finally got this working, with hopes that it will help many others. There are dozens of questions on this topic, many of which have been answered already. It seems silly to &quot;ask it again&quot; just so I can post my own answer to my own question... So, what I'm wondering is, if you've come up with a really good solution to a commonly asked question, what's the best way to share it with the SO community?
116031
I'm trying to write some PHP to upload a file to a folder on my webserver. Here's what I have:  &lt;?php     if ( !empty($_FILES['file']['tmp_name']) ) {         move_uploaded_file($_FILES['file']['tmp_name'], './' . $_FILES['file']['name']);         header('Location: http://www.mywebsite.com/dump/');         exit;     } ?&gt;  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"     "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt; &lt;html&gt;     &lt;head&gt;         &lt;title&gt;Dump Upload&lt;/title&gt;     &lt;/head&gt;     &lt;body&gt;         &lt;h1&gt;Upload a File&lt;/h1&gt;         &lt;form action="upload.php" enctype="multipart/form-data" method="post"&gt;             &lt;input type="hidden" name="MAX_FILE_SIZE" value="1000000000" /&gt;             Select the File:&lt;br /&gt;&lt;input type="file" name="file" /&gt;&lt;br /&gt;             &lt;input type="submit" value="Upload" /&gt;         &lt;/form&gt;     &lt;/body&gt; &lt;/html&gt;   I'm getting these errors:     Warning: move_uploaded_file(./test.txt) [function.move-uploaded-file]: failed to open stream: Permission denied in E:\inetpub\vhosts\mywebsite.com\httpdocs\dump\upload.php on line 3      Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\Temp\phpA30E.tmp' to './test.txt' in E:\inetpub\vhosts\mywebsite.com\httpdocs\dump\upload.php on line 3      Warning: Cannot modify header information - headers already sent by (output started at E:\inetpub\vhosts\mywebsite.com\httpdocs\dump\upload.php:3) in E:\inetpub\vhosts\mywebsite.com\httpdocs\dump\upload.php on line 4   PHP version 4.4.7 Running IIS on a Windows box. This particular file/folder has 777 permissions.  Any ideas?
33987
I am trying to send a value in JavaScript variable to Drupal. I am calling an external js file in hook_nodeapi(). I want to send a value from this external js file to Drupal, and want to use this value in Drupal in hook_block. For example  hook_nodeapi() {   // call(external.js) } external.js var sendData =10;  hook_block {   case view:   // need to access sendData value }   I tried this using cookies, but I think that is not the best way. How can this be done?
123393
Is there a way to upload a file to a FTP server when behind an HTTP proxy ?  It seems that uploading a file is not supported behind an HTTP Proxy using .Net Webclient. ().  If there is no workaround ? If not, do you know a good and free FTP library I can use ?  Edit: Unfortunately, I don't have any FTP proxy to connect to.
18617
I want to Upload File to a Document Library using JavaScript in SharePoint 2010. I found that you can copy file from One Document Library to Another but you can't upload File using JavaScript on this . I want to know exactly that is it really impossible or not. Please help me with that? Its Urgent..
44255
I am trying to insert a chunk of HTML into a div. I want to see if plain JavaScript way is faster than using jQuery. Unfortunately, I forgot how to do it the 'old' way. :P  var test2 = function(){     var cb = function(html){         var t1 = document.getElementById("test2");         var d = document.createElement("div");         d.id ="oiio";         d.innerHtml = html;         t1.appendChild(d);         console.timeEnd("load data with javascript");     };     console.time("load data with javascript");     $.get("test1.html", cb); }   what am i doing wrong here guys?  edit:  Someone asked which is faster, jquery or plain js so i wrote up a test:   plain js is 10% faster
109371
How can an Image-Empty be done with Python?  And how to set an image file on it? Object.data is None for empties, and there is no .image property on the object level either.
103733
Some image hosting sites like Imgur and min.us support image uploading via drag-and-drop in Chrome and Firefox. It would be nice if you could upload an image and add it to your post by dropping it on the edit page.
88037
So i'm trying to submit a form using ajax, in my form i have the following:          $form['actions']['#type'] = 'actions';         $form['actions']['submit'] = array(         '#type' =&gt; 'submit',         '#value' =&gt; $this-&gt;t('OK'),         '#button_type' =&gt; 'primary',         '#prefix' =&gt; '&lt;div class="tc btn_pay relative"&gt;',         '#suffix' =&gt; '&lt;/div&gt;                         &lt;/div&gt;',         '#attributes' =&gt; array(             'class' =&gt; array('proximabold', 'tc', 'transition', 'no-underline', 'ph3', 'pv2', 'mb2', 'dib', 'white'),         ),         '#ajax' =&gt; [             'event' =&gt; 'click',             'callback' =&gt; '::updateTable',             'wrapper' =&gt; 'table-wrapper',             'progress' =&gt; [                 'type' =&gt; 'throbber',                 'message' =&gt; t('Verifying entry...'),             ],         ],     );   and a simple updateTable function:  public function updateTable(array $form, FormStateInterface $form_state) {     return "Hello World"; }   But when i click on submit i get the error: An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (2 MB) that this server supports.  I knew that the error is server side (Maybe i'm wrong), so i went to php.ini (i use PHP7) and update the following lines:  post_max_size = 6144M memory_limit = 6144M upload_max_filesize = 6144M max_file_uploads = 1000   but without luck, this configuration shouldn't be necessary as the request size is only 1.5KB
52925
I built a custom form that saves the data to multiple lists with on click; it works pretty well for its intended use (keeping the data related). Thing is I am totally new at jQuery and SPServices, but am learning.   I would like to know if SPService/jQuery will allow me to use the aspx control to upload a single document to a library? I have seen plugins out there for multiple file uploads so I assume this is possible, but all of these seem way to much for what I am trying to do, and I would like to learn how to do it.  Does anyone know if this is possible? Could provide simple example or explanation or reference?  Appreciate it as always!
112379
I have some use cases where I need to build a web form that includes a way for a site visitor to upload a file (jpeg, png, pdf types)  Any ideas on the best way to do this?