I believe that when a file is selected, this code (below) moves the renamed image file to uploads/ I'd simply like to have the renamed file's path to display on the same page, after it's moved. Can you provide some insight on what's needed to do that? if ($form_submitted == 'yes') { $allowedExts = array("gif", "jpeg", "jpg", "png"); $temp = explode(".", $_FILES["file"]["name"]); $extension = strtolower( end($temp) ); if ( $_FILES["file"]["size"] < 2000000 && in_array($extension, $allowedExts) ) { if ($_FILES["file"]["error"]!= 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br>"; } else { $length = 20; $randomString = substr(str_shuffle(md5(time())),0,$length); $newfilename = $randomString . "." . $extension; move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $newfilename ); $file_location = '<a href="www.--.com/upload/' . $newfilename . '">' . $newfilename . '</a>'; } } else { echo "Invalid upload file"; } $description = $description . " \n " . $newfilename; } PHP: The html part of this is simply: <label for="file">Filename:</label> <input type="file" name="file" id="file"> HTML:
If you mean for it to reload the same page and show the result, you can use this in your code to check if the button was submitted. if ($_POST['submitted']){ $newname=$_POST['newfile']; $url="http://www.--.com/uploads/"; $newfilename=$url.$newname; echo "Your file is stored at $newfilename"; } PHP: Then you would want to add this for your submit button <input type="hidden" name="newfile" value="<?php echo $newfilename; ?>"> <input type="submit" name="submitted" value="Submit"> HTML:
I assume you were trying to make a link here $file_location = '<a href="www.--.com/upload/' . $newfilename . '">' . $newfilename . '</a>'; PHP: So add http:// and modify the link a bit and then echo that variable and it should show you the link. $file_location = '<a href="http://www.--.com/upload/' . $newfilename . '">http://www.--.com/upload/' . $newfilename . '</a>'; echo $file_location; PHP: