twilitegxa Posted September 5, 2010 Share Posted September 5, 2010 Can anyone help me with adding a link to an uploaded file? What I have is a script that allows the user to upload a file, which saves into a folder on the server named "upload". I want to create a link that allows the user to open that file after it is downloaded. Here is what I have so far, but it's not working right. Can anyone help me out? <?php if ((($_FILES["file"]["type"] == "application/msword") || ($_FILES["file"]["type"] == "application/pdf")) && ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file. Only MSWord and PDF documents accepted with size under 1024KB."; } ?> <p>View uploaded resume: <a href="upload/<?php $_FILES["file"]["name"]; ?>">here</a></p> Link to comment https://forums.phpfreaks.com/topic/212561-link-to-view-uploaded-file/ Share on other sites More sharing options...
twilitegxa Posted September 5, 2010 Author Share Posted September 5, 2010 Got it figured out guys, thanks! <a href=upload/" . $_FILES["file"]["name"] . ">" . $_FILES["file"]["name"] . "</a> Link to comment https://forums.phpfreaks.com/topic/212561-link-to-view-uploaded-file/#findComment-1107615 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.