Variable inside an array does not work

Asked

Viewed 627 times

1

is a CLOUDINARY image upload system.

When I use a fixed value for PUBLIC_ID, it works!

$files["remote"] = \Cloudinary\Uploader::upload($sample_paths["couple"],
array_merge($default_upload_options, array(
  "public_id" => '8273',
))

However, when I use a variable for PUBLIC_ID, the result of PUBLIC_ID simply from NULL

$files["remote"] = \Cloudinary\Uploader::upload($sample_paths["couple"],
array_merge($default_upload_options, array(
  "public_id" => "$idbusca",
))

What can be?

1 answer

0


Friend first on

$files["remote"] = \Cloudinary\Uploader::upload($sample_paths["couple"],
array_merge($default_upload_options, array(
  "public_id" => "$idbusca",
))

Remove the double quotes (") around the variable $idbusca.

After this check that this variable is not really empty/null can be this way

echo 'Var $idbusca:<br/><pre>';
var_dump($idbusca);
echo '</pre>';

$files["remote"] = \Cloudinary\Uploader::upload($sample_paths["couple"],
array_merge($default_upload_options, array(
  "public_id" => $idbusca,
))

Because the way it is there it should return the value correctly. If it is really empty the ideal is to go through the code by checking where it has the information and where it "lost".

  • Dude, actually the result of var_dump($idbusca) was NULL, but the same variable is used BEFORE and AFTER and it actually has a value... Please, You have skype?

  • Friend, I’ve got it... The above code was inside: Function do_uploads() {&#xA; global $files, $sample_paths, $default_upload_options, $eager_params;&#xA;&#xA;eu inclui o $idbusca entre essas variaveis, e ficou assim:&#xA;&#xA;function do_uploads() {&#xA; global $files, $sample_paths, $default_upload_options, $eager_params, $idbusca;&#xA;&#xA;THANK YOU VERY MUCH

  • Okay, well, I’m glad to know that you were able to solve it. Don’t forget to positively validate my answers if I helped you. My contact details are on my website https://mfmello.com

Browser other questions tagged

You are not signed in. Login or sign up in order to post.