尝试在路径中使用$ value来移动基于此php文件的文件
I am trying to get the file to upload an image or audio file to the following directory
$dir='sites/default/documents/"$patientID"/'
but I don't know how to use the exact syntax with the $
sign inside a path.
I used the get method to get the patientID from the controller but still nothing is working
我试图让文件将图像或音频文件上传到以下目录 p>
我使用get方法从控制器获取patientID,但仍然无法正常工作 p>
div> $ dir ='sites / default / documents /“$ patientID”/' code>但我不知道如何使用
$ code>的确切语法 在路径内的标志。 p>
Use this instead : $dir="sites/default/documents/$patientID/";
In your case the variable is considered as a text.
Single quotes do not interpolate values, even if there are double quotes inside them. The initial string must be a double quote string, in order for any interpolation to occur inside of it.
If there's any doubt about the complexity of the variable name, use braces to encapsulate the interpolation. $dir="sites/default/documents/{$patientID}/";