PHP Example (original) (raw)
Contributed by PhilCowart and JaisonErickUpdated by Philip Saa
Often sending data to the server, along with the file itself, is needed. Using PHP you'll often use the $_FILES
global to get the file itself and the $_POST
global to get the other fields values. Here are two examples using ngf-upload to send files to PHP backend scripts.
Sending additional data
Upload.upload({ url: 'api/upload-image.php', method: 'POST', file: file, data: { 'awesomeThings': $scope.awesomeThings, 'targetPath' : '/media/' } })
You can handle the data on the backend like this:
filename=filename = filename=_FILES['file']['name']; meta=meta = meta=_POST; destination=destination = destination=meta['targetPath'] . $filename; move_uploaded_file( FILES[′file′][′tmpname′],_FILES['file']['tmp_name'] , FILES[′file′][′tmpname′],destination );