Anyone know how to upload document (docs, pdf) with Laravel to Sharepoint ? i am trying using Microsoft Graph API but still struggling.
in my case i wanna store the data in mysql and sharepoint
here my controller code
namespace AppHttpControllers;
use IlluminateHttpRequest;
use AppModelsFileModel;
use vendorautoload;
use MicrosoftGraphGraph;
use MicrosoftGraphModel;
use MicrosoftGraphGraphServiceClient;
class FileController extends Controller
{
public $microsoftGraphService;
public function __construct(GraphServiceClient $microsoftGraphService)
{
$this->microsoftGraphService = $microsoftGraphService;
}
public function index()
{
$files = FileModel::latest()->paginate(10);
return view('files.index', compact('files'));
}
public function create()
{
return view('files.create');
}
public function store(Request $request)
{
$request->validate([
'file' => 'required|mimes:docx,pdf|max:2048'
]);
$file = $request->file('file');
$fileName = $file->hashName();
$file->storeAs('uploads', $fileName);
FileModel::create([
'original_name' => $file->getClientOriginalName(),
'generate_name' => $fileName
]);
return redirect()
->route('index-docs')`your text`
->with('success', 'Upload Success');
}
}
i cannot find solution, i hope someone will answer this question thank you
New contributor
Rifato is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1