Yes i have this line in my first "upload" case of the switch:
$file_name = $U开发者_如何转开发SER . "-".rand(1, 888).".jpg";
Then in my switch case "crop" (that takes care of the image you crop), I wish to replace the uploaded one with the new one, simply by uploading with same name. Now i cant use $file_name in the case "crop" so how can I do this?
$file_name = "";
switch ($step_name)
{
case "upload":
$file_name = $USER . "-".rand(1, 888).".jpg";
break;
case "crop":
//now you can use $file_name because the scope is outside of the switch statement
break;
default:
break;
}
You would need to place $file_name in a different scope.
A switch is just a lot os IFs. Did you try with IFs?
精彩评论