Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP - Redirect After File is Uploaded to Server
    primarykey
    data
    text
    <p>I have been looking around for a solution to this problem, and thus haven't found one. I'm hoping someone will be able to help me out with this problem.</p> <p>I have this PHP script that gets the posted file, uploads, renames, and moves into a directory:</p> <pre><code>&lt;?php $fileName = $_POST['fileName']; if (!$fileName) $fileName = $distFile.rand(1,999)."-".basename($_COOKIE["email"]); $distFile = dirname(__FILE__).'/audio/'.$fileName.'.wav'; $error = 'N'; $message = 'Your song was uploaded!'; if (!isset($_FILES['wav']) || $_FILES['wav']['error'] &gt; 0) { $error = 'Y'; $message = 'Error while uploading. Error code: '.$_FILES['wav']['error']; } else { $res = @move_uploaded_file($_FILES['wav']['tmp_name'], $distFile); if (!$res) { $error = 'Y'; $message = 'Unable to create the file.'; } } echo ' &lt;?xml version="1.0"?&gt; &lt;response&gt; &lt;error value="'.$error.'" /&gt; &lt;message&gt;'.htmlspecialchars($message).'&lt;/message&gt; &lt;/response&gt; '; ?&gt; </code></pre> <p>That all works fine, however whenever I try to implement a header redirect (like so):</p> <pre><code>&lt;?php $fileName = $_POST['fileName']; if (!$fileName) $fileName = $distFile.rand(1,999)."-".basename($_COOKIE["email"]); $distFile = dirname(__FILE__).'/audio/'.$fileName.'.wav'; $error = 'N'; $message = 'Your song was uploaded!'; if($filename) { header('Location: http://google.co.uk'); } </code></pre> <p>I am unable to refresh the page. I must point out that this script is located in a different file than the page I am trying to reload. This script is located in the file <code>saveWav.php</code> and I am trying to reload <code>index.php</code>.</p>
    singulars
    1. This table or related slice is empty.
    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. 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