Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vipmaa's avatar

error while upload image via restAPI in Plesk

I was create restful API,that API upload image, every thing was great before deploy. I deploy it in Plesk (windowsOS). after that I get a Confusing error

ThrowingCasterException {
message:"Unexpected ErrorException thrown from a caster: file_exists(): open_basedir restriction in effect. File(C:\Windows/composer.json) is not within the allowed path(s): (C:/Inetpub/vhosts/mqr.com\;C:\Windows\Temp\)"}

when i try to validate file its fail

if ($request->file('photo_data')->isValid()) {
            return response()->json([
                'status'=>false,
                'code'=>303,
                'message'=>'Image file is corrupted'
        ]);
}

Any Idea about this error and how can I fix it?

0 likes
1 reply
vipmaa's avatar

Error display when try dd($request->all()) otherwise its fail in validator

 "photo_data" => UploadedFile {#215
    ⚠: ThrowingCasterException {#223
    #message: "Unexpected ErrorException thrown from a caster: file_exists(): open_basedir restriction in effect. File(C:\Windows/composer.json) is not within the allowed path(s): (C:/Inetpub/vhosts/mqr.com\;C:\Windows\Temp\)"
    trace: {
        C:\Inetpub\vhosts\mqr.com\api.mqr.com\vendor\symfony\var-dumper\Caster\LinkStub.php:92: {
        : $parent = $dir;\r
        : while (!file_exists($parent.'/composer.json')) {\r
        :     if ($parent === dirname($parent)) {\r
        }
        Illuminate\Foundation\Bootstrap\HandleExceptions->handleError():    {}
        C:\Inetpub\vhosts\mqr.com\api.mqr.com\vendor\symfony\var-dumper\Cloner\AbstractCloner.php:205: {
        : if ($this->prevErrorHandler) {\r
        :     return call_user_func($this->prevErrorHandler, $type, $msg, $file, $line, $context);\r
          : }\r
        }
      Symfony\Component\VarDumper\Cloner\AbstractCloner->Symfony\Component\VarDumper\Cloner\{closure}(): {}
        C:\Inetpub\vhosts\mqr.com\api.mqr.com\vendor\symfony\var-dumper\Caster\LinkStub.php:92: {
          : $parent = $dir;\r
        : while (!file_exists($parent.'/composer.json')) {\r
        :     if ($parent === dirname($parent)) {\r
        }
        C:\Inetpub\vhosts\mqr.com\api.mqr.com\vendor\symfony\var-dumper\Caster\LinkStub.php:53: {
        : }\r
        : if ($composerRoot = $this->getComposerRoot($href, $inVendor))     {\r
          :     $this->attr['ellipsis'] = strlen($href) - strlen($composerRoot) +   1;\r
        }
        C:\Inetpub\vhosts\mqr.com\api.mqr.com\vendor\symfony\var-dumper\Caster\SplCaster.php:119: {
         : if (isset($a[$prefix.'realPath'])) {\r
        :     $a[$prefix.'realPath'] = new LinkStub($a[$prefix.'realPath']);\r
        : }\r
      }
    }
    }
    -test: false
    -originalName: "Screenshot from 2017-08-05 12-32-26.png"
    -mimeType: "image/png"
    -size: 42120
    -error: 0
    #hashName: null
}

Please or to participate in this conversation.