Image Upload in PHP
Posted: Wed Sep 19, 2007 10:50 pm
scottayy | Please use
Any suggestion what is wrong with the above code?
Any help would be greatly appreciated.
Thanks
scottayy | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I am trying to upload a image from my computer to the "Image" Folder created in C:\wamp\www\.(My Document root is set to C:/wamp/www/test) & when I run this program it should display the image in the same browser window.But the following code is not working.Code: Select all
<html>
<head><title>Upload Files</title>
</head>
<body>
</br>
<center>
<form action="upload.php" method="POST" enctype="multipart/form-data">
<input type="file" name="img"/><br>
<input type="submit" value="click to upload" name="sub">
</form>
<? php
if(isset($_POST['sub']))
{
$file=$_FILES["img"]["name"];
$dir="images/";
$tot_dir=$dir.$file;
if(move_uploaded_file($_FILES["img"]["tmp_name"],$tot_dir))
{
?>
<img src="images/<?php echo $file; ?> "border="0" />
<?php
}
?>
</center>
</body>
</html>Any help would be greatly appreciated.
Thanks
scottayy | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]