Created
December 23, 2014 09:58
-
-
Save alfiebesin/6c26e645cf9fd954cfa3 to your computer and use it in GitHub Desktop.
Netsuite Upload image to File Cabinet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once '../PHPToolkit/NetSuiteService.php'; | |
$service = new NetSuiteService(); | |
$uploadFile = new File(); | |
$uploadFile->name = 'SD Sample Image 9'; | |
$uploadFile->attachFrom = '_computer'; | |
$path = 'alfie.jpg'; | |
$type = pathinfo($path, PATHINFO_EXTENSION); | |
$data = file_get_contents($path); | |
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data); | |
$base64Image = $base64; | |
$uploadFile->content = $base64Image; | |
$folderRef = new RecordRef(); | |
$folderRef->internalId = 19; | |
$uploadFile->folder = $folderRef; | |
$uploadFile->fileType = '_JPGIMAGE'; | |
$uploadFile->mediaTypeName = 'JPEG Image'; | |
$request = new AddRequest(); | |
$request->record = $uploadFile; | |
$addResponse = $service->add($request); | |
if (!$addResponse->writeResponse->status->isSuccess) { | |
echo "ADD ERROR"; | |
echo '<pre>'; | |
print_r($addResponse); | |
} else { | |
echo "ADD SUCCESS, id " . $addResponse->writeResponse->baseRef->internalId; | |
echo '<pre>'; | |
print_r($addResponse); | |
} |
Try
$uploadFile->folder = new RecordRef();
$uploadFile->folder->internalId = 19;
instead of
$folderRef = new RecordRef();
$folderRef->internalId = 19;
$uploadFile->folder = $folderRef;
Hi,
Can we save image directly form web URL?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
HI , I want to know how to upload pdf file into NetSuite API.
I tried to upload PDF file but the error is coming ' Please enter value(s) for: Folder'
what value will come in the FIle url.
Please help me out in this.
Thank you