title: Write to tmp folder
body: <p><strong>EDIT 1</strong></p>
  
  <p>This question involves the user of the <a href="https://github.com/Mangopay/mangopay2-php-sdk" rel="nofollow noreferrer">MANGOPAY API</a>. My problem is that I cannot get the API to write to the <code>tmp</code> folder. </p>
  
  <p>I have succeeded in getting the API to write to <code>http://fakedomain.com/apifolder/blank.txt</code> and getting the appropriate output. </p>
  
  <p>I then ran the script <code>http://fake.com/apifolder/demos/iswrite.php</code> on <code>http://fakedomain.com/apifolder/blank.txt</code> to have minimal working code I could test on the <code>tmp</code> folder. Here is the code in the script:</p>
  
  <pre><code>&lt;?php
  
  $filename = 'blank.txt';
  
  
  echo "&lt;br&gt;";
  
  
  file_exists($filename);
  
  echo "&lt;br&gt;";
  
  
  
  if (file_exists($filename)) {
      echo "The file $filename exists";
  } else {
      echo "The file $filename does not exist";
  }
  
  echo "&lt;br&gt;";
  
  if (is_writable($filename)) {
      echo 'The file is writable';
  } else {
      echo 'The file is not writable';
  }
  
  ?&gt;
  </code></pre>
  
  <p>It gives me the output</p>
  
  <p><code>The file blank.txt exists
  The file is writable</code></p>
  
  <p>so all good there. I created the following file with the following permissions using Filezilla:</p>
  
  <p><a href="https://i.stack.imgur.com/ivQFQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ivQFQ.png" alt="enter image description here"></a></p>
  
  <p>In the script <code>http://fake.com/apifolder/demos/iswrite.php</code> I have changed the filename variable to <code>$filename = 'http://fake.com/tmp/creative/blank.txt';</code>. It gives me the following output:</p>
  
  <p><code>The file http://fake.com/tmp/creative/blank.txt does not exist
  The file is not writable</code></p>
  
  <p>Also, <code>allow_url_fopen</code> is on. </p>
  
  <p>I don't fully understand URL structures, so maybe the problem lies there? The tmp folder I am trying to access is on the same level as my <code>public_html</code> folder. Maybe I am writing my URLs wrong?</p>
  
  <p><a href="https://i.stack.imgur.com/ThaRd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ThaRd.png" alt="enter image description here"></a></p>
  
  <p><strong>Put in another way, does the <code>tmp</code> folder have to be outside the <code>public_html</code> folder? Would there be any purpose to this? Or can I have create my own <code>tmp</code> folder within <code>public_html</code> where it is already working?</strong> </p>
  
  <hr>
  
  <p><strong>ORIGINAL QUESTION</strong></p>
  
  <p><strong>The original question was poorly written. Please see EDIT 1</strong></p>
  
  <p>I am playing with the sandbox of an API (<a href="https://github.com/Mangopay/mangopay2-php-sdk" rel="nofollow noreferrer">MangoPay</a>). I have included my ClientId and ClientPassword which seems to work. </p>
  
  <p>The API also says... </p>
  
  <blockquote>
    <p>You also need to set a folder path in $api->Config->TemporaryFolder
    that SDK needs to store temporary files. This path should be outside
    your www folder. It could be /tmp/ or /var/tmp/ or any other location
    that PHP can write to.</p>
  </blockquote>
  
  <p>I have created one at:</p>
  
  <p><code>ftp://fakedomain@fakedomain/tmp/fakefoldername</code></p>
  
  <p>I am running the php script from my desktop using Terminal. The output it is giving me is </p>
  
  <blockquote>
    <p>Cannot create or write to file
    <code>ftp://fakedomain@fakedomain/tmp/fakefoldername</code></p>
  </blockquote>
  
  <p>even though I have set permissions to 777. </p>
  
  <p>Any idea of why I am getting this error?</p>