<form enctype="multipart/form-data" action="profile. php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="5000000">
<input type="file" name="upfile">
<input type="submit" name="submit2" value="upload">
</form>
<?php
$conn = mysql_connect("localhost", "342137", "342137");
mysql_select_db("342137", $conn);
$username = $_SESSION['loggeduser'];
?>
<?php
if(isset($_POST['submit2']))
{
$uploaddir = "profile/";
$filename = $_FILES['upfile']['name'];
$filename = trim($filename);
$uploadfile = $uploaddir . $username . ". jpg";
$result = move_uploaded_file($_FILES['upfile'][tm… $uploadfile);
if($result != 0)
{
chmod($uploadfile, 0644);
}
else
{
print("File upload failed");
}
}
?>
<br>
<?php
$dir = "profile/";
if ($dh = @opendir($dir)) {
$file = $dir . $username . ". jpg";
if(file_exists($file))
print("<img src='$file' height='125px' width='137px'>");
closedir($dh);
}
?>
This webpage is created to upload a jpg image and to display that image. but when i run this page with wampserver then it works properly and upload the image and then display. but when i run this page with orgfree. com (web based FTP client) then the error message "file upload failed" appears.
what's the problem? how to solve it? please help me.