stargatesg1's avatar

forge issue uploading files

In my Laravel application i can upload files thru a browser i created. The files go to app/storage/files. This only works localy when I upload the files. But on the live server it doesn't is there anything i need to do on the live server site?

Here is the upload code

 public function uploadFile(Request $request){

        $file = $request->file('file');
         $path="";

        $trackCat= $request->header('trackCategory');

        switch ($trackCat) {
            case 1:
               $path="muti";
            break;

            case 2:
                $path="over";
             break;

            case 3:
                $path="pra";
            break;

            default:
                $path="muti";
        }

        /*Check to see if its a image we are uploading */
        $imageMatch=preg_match("/\b(\.jpg|\.JPG|\.png|\.PNG|\.gif|\.GIF)\b/", $file->getClientOriginalName(), $output_array);

        if($imageMatch==1){
             $file->store('tracks/'.$path.'/images');
        }

        if($imageMatch==0){
             $file->store('tracks/'.$path);
        }



        /*Return response */
        return response()->json([
            'filename' => $file->hashName(),
            'trackCategory' => $trackCat,
            'extension' => $file->getClientOriginalName()
        ]);

    }

0 likes
2 replies
clin407's avatar

What exactly happens on the live site?

ejdelmonico's avatar

If you want the files available publicly on the live site, you need to run php artisan storage:link. It's in the docs for further explanation.

Please or to participate in this conversation.