scp copy has error "ambiguous target"

If you have white space in a path, you have to escape the characters by using double backslashes \\ and enclosing the entire path in quotes:

scp myfile.txt [email protected]:"/file\\ path\\ with\\ spaces/myfile.txt"

I found that two sets of quotes worked for me, around the target location. Double quotes outside, and single quotes inside the double quotes. For example:

scp "my local file.txt" [email protected]:"'/folder/my spacey folder name/'"

The outside set of quotes are for the local shell, and the inside quotes are for the remote shell. Thanks to @mik for the suggestion in comments.