Re Upload a file to SharePoint Doc Library sp 2013

I am working in SP 2013 on-Premise. I am trying to re-upload documents from a folder in my local machine to my document Library. The code works fine. However on downloading the document I see no change in the document content even though the version gets updated (this may be because I am also updating a field)

I am using CSOM SaveBinaryDirect method. This is my code :

FileStream stream = new FileStream(filename, FileMode.Open); Microsoft.SharePoint.Client.File.SaveBinaryDirect(context, path, stream, true); var uploadedfile = context.Web.GetFileByServerRelativeUrl(path); context.Load(uploadedfile); context.ExecuteQuery(); if(uploadedfile.CheckOutType == CheckOutType.None) { uploadedfile.CheckOut(); } context.ExecuteQuery(); var listitem = uploadedfile.ListItemAllFields; listitem[“column”] = “Value”; listitem.Update(); context.ExecuteQuery(); listitem.File.CheckIn(“”, CheckinType.MajorCheckIn); context.ExecuteQuery();

Any help would be appreciated!

What file enforcement should be set on file upload for best user experience?

We make website and we want our users to do things as they are supposed to. But it’s not like everyone knows everythings…

I’m creating a website ashiane.house that suppose to allow user to share their property information with other, in term of Selling, Renting, etc…

As we all knows these kind of websites, do not have a specific operator, and all kinds of user work with them, from professionals to people who may only use the computer for only necessity.

So is it good to enforce Specific image type? what type of image other than JPEG should we allow? what’s the minimum file size that we should allow our users? do typical users knows how to decrease image size?

2016 – Upload multiple files with REST API and PNP

I’m developing a multiple files upload form on SharePoint 2016.

My goal is to prevent duplicate files name, so my idea is to upload files in a document library, change a metadata of these files and then move these files to another document library changing their filenames to prevent duplicate.

So there are three main steps:

1) Files upload

2) Change files metadata

3) Move to another document library with a new file name (es.: myfile-timestamp.ext)

I’ve tried several ways, using PNP JS, but I did not find a solution.

This is my code that’s is quite messy:

function UploadFiles() {     var loadFiles = document.getElementById('loadFile').files;      //in case of multiple files,iterate or else upload the first file.     for (var i=0; i<=loadFiles.length;i++){         var fileOgg = loadFiles[i];         if (fileOgg!=undefined || fileOgg!=null){             var nameFile = fileOgg.name;             var timestamp = + new Date();             var fileName = nameFile.substr(0, nameFile.lastIndexOf('.'));             var newfileName = fileName + "-" + timestamp;             var sourceFileUrl = _spPageContextInfo.webServerRelativeUrl+"/Config/"+nameFile+"";             var targetFileUrl = _spPageContextInfo.webServerRelativeUrl+"/Attachments/"+nameFile.replace(fileName, newfileName)+"";              new Promise(function (resolve, reject) { resolve (); })             .then(UploadFilesStep.bind(null, fileOgg, true))             .then(function(fileUpload) {                  changeMetadata(fileUpload)                 .then(moveTo.bind(null, sourceFileUrl, targetFileUrl, nameFile, fileName, newfileName))                 .then(showSuccess)              });         }     }    }  function UploadFilesStep (fileOgg, overwrite){     return new Promise(function(resolve, reject) {         pnp.setup({ headers: { "Cache-Control": "no-cache", }, });         pnp.sp.web.getFolderByServerRelativeUrl("/sites/testpcr/Config").files.add(fileOgg.name, fileOgg, overwrite).then(function(result) {             console.log("FileUpload success");             resolve(result);          });        }) }  function changeMetadata(result) {     return new Promise(function(resolve, reject) {         result.file.listItemAllFields.get().then(function(listItemAllFields) {             // get the item id of the file and then update the columns(properties)             pnp.setup({ headers: { "Cache-Control": "no-cache", }, });   pnp.sp.web.lists.getByTitle("Config").items.getById(listItemAllFields.Id).update({                 Number: ""+number+"",             }).then(function(r){                 console.log(" properties updated successfully! Go to MoveTo");                 resolve();             });         });     }) }  function moveTo(sourceFileUrl, targetFileUrl, nomeFile, fileNome, nuovoFileNome) {     return new Promise(function(resolve, reject) {         var headers = headers || {};         var method = 'POST';         headers["Accept"] = "application/json;odata=verbose";         headers["X-RequestDigest"] = $  ("#__REQUESTDIGEST").val();         var endpointUrl = siteurl2 + "/_api/web/GetFileByServerRelativeUrl('" + sourceFileUrl + "')/MoveTo(newurl='" + targetFileUrl + "',flags=1)";         var payload;          $  .ajax({             url: endpointUrl,             type: method,             contentType: "application/json;odata=verbose",             data: JSON.stringify(payload),             cache: false,             headers: headers,             async: false,             success: function (data) {                 strResults += "";                 contatoreUpload = contatoreUpload + 1;                 resolve();             },             error: function (data) {                 strResults += "Error " + JSON.stringify(data, null, 4);;                 resolve();             }         });     });  } 

Do you have any example or different solution?

Is it safe to upload videos in cloud tools like video editors?

What i have is a video file(with delicate pieces of frames in it) that i want to be edited using cloud apps, without looking further in site maps and thats not always possible too, if you have to share that file instantly, i’m not sure that general assurance of discreteness will be applied by the site owners and even will be deleted if i ask for that. that must make sure it may not fall in things where its not intended to be used by someone, so i can share personal data. can owner rights be lost, or will high valuable information in upload files be lost, and security people are not often faced to upload their files to random sites to edit their work?

many tools are availible to give personal data away, https://clideo.com/ ..

Upload de arquivo não envia

Estou tentando fazer o upload de arquivo, mas não envia para a pasta. Mostra todo o processo de envio do arquivo, recebe no banco de dados o novo nome do arquivo, mas o arquivo não chega na pasta do servidor.

<?php if ((isset($  _POST["form"])) && ($  _POST['form'] == "form1")) {    $  ext = strtolower(substr($  _FILES['arquivo']['name'],-4)); //Pegando extensão do arquivo   $  arquivo = "file_".date('dmYhis') . $  ext; //Definindo um novo nome para o arquivo   $  dir = __DIR__.'/uploads/aulas/'; //Diretório para uploads   move_uploaded_file($  _FILES['arquivo']['tmp_name'], $  dir.$  arquivo); //Fazer upload do arquivo  } ?>     <form id="form" method="post" autocomplete="off" enctype="multipart/form-data">     <div class="row">       <div class="col-xs-6">         <div class="form-group">           <label class="control-label">Arquivo (.zip .rar .pdf)</label>           <input name="arquivo" type="file" id="file-1" required />         </div>       </div>        <button type="submit" id="button" name="button" class="btn btn-success pull-right"><i class="icon-save bigger-110"></i> Salvar</button>   </form> 

Problemas em upload de arquivo em multipart/form-data. C#

Olá, meu problema é o seguinte, tenho uma simples aplicação web rodando no apache em localhost.

Qual possui o seguinte código:

<?php if (isset($  _FILES['arquivo'])) {     move_uploaded_file($  _FILES['arquivo']['tmp_name'], "uploadedfile.pdf");  }  ?>    <HTML> <form method="POST" enctype="multipart/form-data"> <input type="file" name="arquivo" id="arquivo"/> <input type="submit" value="click here to send"/> </form>  </HTML> 

Gostaria de saber como posso efetuar o envio do meu arquivo desejado em c# utilizando httpwebrequest.

Tentei o seguinte:

public string Upload(string filePath)         {             string formdataTemplate = "Content-Disposition: form-data;name=\"arquivo\" ;filename=\"{0}\";\r\nContent-Type: application/pdf\r\n\r\n";             string boundary = "---------------------------" + DateTime.Now.Ticks.ToString("x");             byte[] boundarybytes = Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");              HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost/xxxx/fileuploader.php");             request.ServicePoint.Expect100Continue = false;             request.Referer = "http://localhost/policlinica/fileuploader.php";             request.KeepAlive = false;             request.Method = "POST";             request.CookieContainer = cookieContainer;             request.ContentType = "multipart/form-data; boundary=" + boundary;              using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))             {                 using (Stream requestStream = request.GetRequestStream())                 {                     requestStream.Write(boundarybytes, 0, boundarybytes.Length);                     string formitem = string.Format(formdataTemplate, Path.GetFileName(filePath));                     byte[] formbytes = Encoding.UTF8.GetBytes(formitem);                     requestStream.Write(formbytes, 0, formbytes.Length);                     byte[] buffer = new byte[1024 * 4];                     int bytesLeft = 0;                      while ((bytesLeft = fileStream.Read(buffer, 0, buffer.Length)) > 0)                     {                         requestStream.Write(buffer, 0, bytesLeft);                     }                  }             }              try             {                 using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())                 {                     var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();                     return responseString;                 }              }             catch (WebException ex)             {                 return ex.ToString();             }         } 

Porém sem exito.

Obrigado.

“Bad request” when trying to upload file

I am trying to upload file via C#, I copy pasted the code from here.

I just added inside the constructor my credentials, like:

public SharePointClient(string webUri) {    Credentials=new NetworkCredential("myusername","mypassword"); } 

And I’m calling the upload function from the main class:

var url="http://codey-sharepoint/sites/codey"; var sharepoint=new SharePointClient(url); sharepoint.UploadFileAsChuncks(url,"D:\test.txt"); 

But, I’m getting “BadRequest” exception at:

... if (firstChunk) {    endpointUrl = string.Format("{0}/_api/web/getfilebyserverrelativeurl('{1}')/startupload(uploadId=guid'{2}')", BaseAddress, uriAddress.LocalPath, uploadId);     this.UploadData(endpointUrl, buffer);   //<----- here exception     firstChunk = false; } 

Any suggestions?