How can a PHP script be modified to display a direct link to the uploaded file instead of a list?

To modify a PHP script to display a direct link to the uploaded file instead of a list, you can simply use the file path of the uploaded file to create a direct link. This can be done by echoing an anchor tag (<a>) with the href attribute set to the file path.

&lt;?php
if ($_FILES[&#039;file&#039;][&#039;error&#039;] === UPLOAD_ERR_OK) {
    $uploadDir = &#039;uploads/&#039;;
    $uploadFile = $uploadDir . basename($_FILES[&#039;file&#039;][&#039;name&#039;]);
    
    if (move_uploaded_file($_FILES[&#039;file&#039;][&#039;tmp_name&#039;], $uploadFile)) {
        echo &#039;File uploaded successfully. Direct link: &lt;a href=&quot;&#039; . $uploadFile . &#039;&quot;&gt;&#039; . $uploadFile . &#039;&lt;/a&gt;&#039;;
    } else {
        echo &#039;Error uploading file.&#039;;
    }
}
?&gt;