Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use the <strong>fwrite</strong> function (this is probably not a very good idea in this particular example though.</p> <pre><code>$fp = fopen('data.txt', 'w'); fwrite($fp, $yourContents); fclose($fp); </code></pre> <p>But, if you already have the file simply copy it using the copy command (if you want to keep it in the temp folder that is, if not move it with the rename function instead).</p> <p>To <strong>copy</strong>, do something like this</p> <pre><code>$tempfile = 'tempfile.txt'; $newfile = 'newfile.txt'; if (copy($tempfile, $newfile)) { echo "success!"; } else { echo "misery :("; } </code></pre> <p>To move with <strong>rename</strong></p> <pre><code>// Rename returns a bool, just as in the copy example rename("/tmp/tempfile.txt", "/home/user/files/newfile.txt"); </code></pre> <p><strong>Added this:</strong> To move with <strong>move_uploaded_file</strong></p> <p><em>Please note, I didn't test this in a development environment. This may not execute perfectly.</em></p> <pre><code>$uploads_dir = 'C:\\movefiles\\here\\'; foreach ($_FILES["upload-tracking-file"]["error"] as $key =&gt; $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["upload-tracking-file"]["tmp_name"][$key]; $name = $_FILES["upload-tracking-file"]["name"][$key]; move_uploaded_file($tmp_name, "$uploads_dir\\$name"); } } </code></pre> <p><strong>References</strong> </p> <ul> <li>Copy, <a href="http://php.net/manual/en/function.copy.php" rel="nofollow">http://php.net/manual/en/function.copy.php</a></li> <li>Move (rename), <a href="http://php.net/manual/en/function.rename.php" rel="nofollow">http://php.net/manual/en/function.rename.php</a></li> <li>move_uploaded_file, <a href="http://php.net/manual/en/function.move-uploaded-file.php" rel="nofollow">http://php.net/manual/en/function.move-uploaded-file.php</a></li> <li>fwrite, <a href="http://php.net/manual/en/function.fwrite.php" rel="nofollow">http://php.net/manual/en/function.fwrite.php</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload