title: curl: (26) couldn't open file when the file is a variable
body: <p>I am trying to upload a list of files to a server. This is the script that I have</p>
  
  <pre><code>files=$(shopt -s nullglob dotglob; echo /media/USB/*) &gt; /dev/null 2&gt;&amp;1
  if (( ${#files}  ))
      then
              for file in $files
              do
                      echo "Filename"
                      echo $file
                      curl -i -X POST -F files=@$file 192.168.1.122:5000/upload
              done
  </code></pre>
  
  <p>Basically I am trying to take all of the files on a USB drive and upload them to my local server. The curl command is giving me trouble. I can move these files to drives that I mount on this system but I haven't been able to send them with the curl command. I have tried variations on <code>@"$file"</code> and <code>@\"$file\"</code> based on other related questions but I haven't been able to get this to work. However what is annoying is that when I do this:</p>
  
  <pre><code>curl -i -X POST -F files=@/absolute/path/to/my/file.txt 192.168.1.122:5000/upload
  </code></pre>
  
  <p>It works as I expect. How can I get this to work in my loop?</p>