How to get file upload without a form

The Request has a FileBag, similar to the ParameterBag So I could get the file specified easily with: $data = $this->getRequest()->request->all(); $file = $this->getRequest()->files->get(‘file’); and use the document as is from the cookbook: $document = new Document(); $document->setFile($file); $lead->setDocument($document);

Upload file to SFTP using PowerShell

You didn’t tell us what particular problem do you have with the WinSCP, so I can really only repeat what’s in WinSCP documentation. Download WinSCP .NET assembly. The latest package as of now is WinSCP-5.21.8-Automation.zip; Extract the .zip archive along your script; Use a code like this (based on the official PowerShell upload example): # … Read more

File uploading using GET Method

GET requests may contain an entity body RFC 2616 does not prevent an entity body as part of a GET request. This is often misunderstood because PHP muddies the waters with its poorly-named $_GET superglobal. $_GET technically has nothing to do with the HTTP GET request method — it’s nothing more than a key-value list … Read more

Using MultipartPostHandler to POST form-data with Python

It seems that the easiest and most compatible way to get around this problem is to use the ‘poster’ module. # test_client.py from poster.encode import multipart_encode from poster.streaminghttp import register_openers import urllib2 # Register the streaming http handlers with urllib2 register_openers() # Start the multipart/form-data encoding of the file “DSC0001.jpg” # “image1” is the name … Read more

Preview Image before uploading Angularjs

OdeToCode posted great service for this stuff. So with this simple directive you can easily preview and even see the progress bar: .directive(“ngFileSelect”,function(){ return { link: function($scope,el){ el.bind(“change”, function(e){ $scope.file = (e.srcElement || e.target).files[0]; $scope.getFile(); }); } } It is working in all modern browsers! Example: http://plnkr.co/edit/y5n16v?p=preview

How do you upload a file to a document library in sharepoint?

You can upload documents to SharePoint libraries using the Object Model or SharePoint Webservices. Upload using Object Model: String fileToUpload = @”C:\YourFile.txt”; String sharePointSite = “http://yoursite.com/sites/Research/”; String documentLibraryName = “Shared Documents”; using (SPSite oSite = new SPSite(sharePointSite)) { using (SPWeb oWeb = oSite.OpenWeb()) { if (!System.IO.File.Exists(fileToUpload)) throw new FileNotFoundException(“File not found.”, fileToUpload); SPFolder myLibrary = … Read more

mkdir() says theres no such directory and fails?

It happens because you don’t have images/listing-images/rent path existing in your filesystem. If you want to create the whole path – just pass the 3rd argument as a true: mkdir(‘images/listing-images/rent/’.$insertID, 0777, true); There is also a chance you’re in a wrong directory currently. If this is the case – you need to change the current … Read more

How to test file upload in Laravel 5.2

When you create an instance of UploadedFile set the last parameter $test to true. $file = new UploadedFile($path, $name, filesize($path), ‘image/png’, null, true); ^^^^ Here is a quick example of a working test. It expects that you have a stub test.png file in tests/stubs folder. class UploadTest extends TestCase { public function test_upload_works() { $stub … Read more