title: PHP file upload (via Curl on the command line)
body: <p>I'm having a nightmare using PHP to upload files to my server, however when using this simple HTML form, it appears to work:</p>
  
  <pre><code>&lt;html&gt;&lt;body&gt;
  &lt;form enctype="multipart/form-data" action="uploads.php" method="POST"&gt;
  &lt;input type="hidden" name="MAX_FILE_SIZE" value="100000" /&gt;
  Choose a file to upload: &lt;input name="uploadedfile" type="file" /&gt;&lt;br /&gt;
  &lt;input type="submit" value="Upload File" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p></p>
  
  <p>The PHP is then:</p>
  
  <pre><code>&lt;?php
  $target_path = "uploads/";
  $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
  if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
  echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
  " has been uploaded";
  } else{
  echo "There was an error uploading the file, please try again!";
  }
  ?&gt;
  </code></pre>
  
  <p>Is there any possible way to send a file via this technique using curl from the command line or a shell script?   i.e something along the lines of:</p>
  
  <pre><code>curl -f "@/path/to/my/file;type=text/html" http://mywebserver.com/uploads.php
  </code></pre>
  
  <p>That particular line gives me: "curl: (22) Failed to connect to ::1: Permission denied" although there is no password on the site etc.  I assume this is possible, but I'm getting the syntax wrong?</p>