dragonmarch's avatar

Upload file from laravel web in ubuntu to shared folder in windows7

I can upload this file to my server but I can't upload to shared folder from window7. I can access that folder from ubuntu desktop. When i upload it show error like: The file "test.txt" was not uploaded due to an unknown error.

My code:

$oderdata = $request->file('orderdata');
$input['orderdata'] = time().'_'.$orders.'_'.$oderdata->getClientOriginalName();
$destinationPath = public_path('/assets/shared/'.Auth::user()->gettaxid()->taxid.'/order/rawdata');
$oderdata->move($destinationPath, $input['orderdata']);
$oderdata->move('smb://MyServer/receipt/Raw', $input['orderdata']);

Thank you for help.

0 likes
6 replies
Snapey's avatar

you already moved it once. How can you move it a second time?

dragonmarch's avatar

@Snapey I change my code to:

$oderdata = $request->file('orderdata');
$input['orderdata'] = time().'_'.$orders.'_'.$oderdata->getClientOriginalName();
$destinationPath = public_path('/assets/shared/'.Auth::user()->gettaxid()->taxid.'/order/rawdata');
$oderdata->move($destinationPath, $input['orderdata']);
copy($destinationPath.'/'.$input['orderdata'],"smb://MyServer/receipt/".$input['orderdata'])

And i got error like:

copy(smb://MyServer/receipt/1529917915_202_testxxx.txt): failed to open stream: operation failed
Snapey's avatar

well go back to your original code because what you have now is clearly wrong

just change the first move to copy.

i would be suprised if smb works though

$oderdata = $request->file('orderdata');
$input['orderdata'] = time().'_'.$orders.'_'.$oderdata->getClientOriginalName();
$destinationPath = public_path('/assets/shared/'.Auth::user()->gettaxid()->taxid.'/order/rawdata');
$oderdata->copy($destinationPath, $input['orderdata']);
$oderdata->move('smb://MyServer/receipt/Raw', $input['orderdata']);
dragonmarch's avatar

@Snapey Get error:

BadMethodCallException
Method Illuminate\Http\UploadedFile::copy does not exist.
Snapey's avatar

Sorry I was getting confused with file object. You need to use store or storeAs

Probably best to setup a filesystem for the windows destination, else storeAs and then copy to additional location

dragonmarch's avatar
dragonmarch
OP
Best Answer
Level 1

@Snapey Thank you for help. Now I change code and my destination server to FTP it very easy way to tranfer.

I will try normal upload for next time.

Please or to participate in this conversation.