About File uploading

0 Parth Patwala · September 7, 2014
Hello.
I successfully uploaded fie or you can say i save uploaded fie in to new location.
.
.
But now i want to display link into browser to open that uploaded file. Any ideas?

Post a Reply

Replies

Oldest  Newest  Rating
0 Steven the awesome · September 8, 2014
So if I am correct you want, to show your picture after uploading it. 
0 Parth Patwala · September 10, 2014
Yes. but i think i already did it. 
 see here
 <?php
$name = @$_FILES['file']['name'];
//$size = @$_FILES['file']['size'];
//$type = @$_FILES['file']['type'];
$tmp_name = @$_FILES['file']['tmp_name'];
if(isset($name)){
if(!empty($name)){
$location = 'uploads/';
if(move_uploaded_file($tmp_name,$location.$name)){
echo 'uploaded.<br>';
echo '<a href="http://localhost/work/uploads/'.$name.'"> Open uploaded file.</a>';
}else{
echo 'There was an error.';
}
}else{
echo 'Please choose a file.';
}
}
?>
<form action="prac5_4.php" method="POST" enctype="multipart/form-data">
<input type="file" name="file"><br><br>
<input type="submit" value="Submit" name="b1" />
</form>
  • 1

PHP

107,029 followers
About

Server-side, HTML embedded scripting language used to create dynamic Web pages.

Links
Moderators