I searched for some solution and it seems can work by adding some code in it. My codes seems doesn't work. I don't know what to do. I'm new in php. The input type file seems working but the upload button doesn't work and it seems that is the problem of this.
<?php
include ('LoginFunction.php');
$conn = mysqli_connect('localhost','root','','danganan');
$user = $_SESSION['Username'];
$query = "SELECT * FROM tblactivity WHERE Username = '$user'";
$result = mysqli_query($conn,$query);
$row = mysqli_fetch_array($result);
This is the upload function
if (isset($_POST['upload'])) {
$file_name = $_FILES['file']['name'];
$file_type = $_FILES['file']['type'];
$file_size = $_FILES['file']['size'];
$file_tem_loc = $_FILES['file']['tmp_name'];
$file_store = "uploads/".$file_name;
if(move_uploaded_file($file_tem_loc, $file_store)) {
echo "Image uploaded!";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Profile info</title>
</head>
<body>
<form method="POST">
<div class="container">
<h1><?php echo "Welcome " . " " . $user; ?></h1>
<img src="<?php $row['Picture']; ?>" width=150; height=150;>
<div class="send-button">
<input type="file" name="file" style="margin-right: -76px;"><br><br>
<input type="submit" name="upload" value="Upload">
<?php
$folder = "uploads/";
if(is_dir($folder)) {
if ($open = opendir($folder)) {
while (($file = readdir($open)) !=false) {
if($file == '.' || $file == '..') continue;
echo '<img src ="uploads/'.$file.'" width = "150" height=150>';
}
closedir($open);
}
}
?>
</div>
<input type="hidden" name="usrid" value="<?php echo $row['ID']; ?>">
<h2>FIRST NAME</h2><input type="text" name="fname" value="<?php echo $row['Fname']; ?>">
<h2>LAST NAME</h2><input type="text" name="lname" value="<?php echo $row['Lname']; ?>">
<h2>USERNAME</h2><input type="text" name="uname" value="<?php echo $row['Username']; ?>">
<h2>PASSWORD</h2><h3><?php echo $row['Password']; ?></h3>
</form>
</body>
</html>
Related
i am using below code to upload an image through php form in fresh file, its working fine.
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
</html>
<?php
if (isset($_FILES["photo"]["error"])) {
if ($_FILES["photo"]["error"] > 0) {
echo "Error: " . $_FILES["photo"]["error"] . "<br>";
} else {
$allowed = array("jpg" => "image/jpg", "jpeg" => "image/jpeg", "gif" => "image/gif", "png" => "image/png");
$filename = $_FILES["photo"]["name"];
$filetype = $_FILES["photo"]["type"];
$filesize = $_FILES["photo"]["size"];
// Verify file extension
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if (!array_key_exists($ext, $allowed))
die("Error: Please select a valid file format.");
// Verify file size - 5MB maximum
$maxsize = 5 * 1024 * 1024;
if ($filesize > $maxsize)
die("Error: File size is larger than the allowed limit.");
// Verify MYME type of the file
if (in_array($filetype, $allowed)) {
// Check whether file exists before uploading it
if (file_exists("upload/" . $_FILES["photo"]["name"])) {
echo $_FILES["photo"]["name"] . " is already exists.";
} else {
move_uploaded_file($_FILES["photo"]["tmp_name"], "upload/" . $_FILES["photo"]["name"]);
echo "Your file was uploaded successfully.";
}
} else {
echo "Error: There was a problem uploading your file - please try again.";
}
}
} else {
echo "Error: Invalid parameters - please contact your server administrator.";
}
?>
but when i used same code in already existed form page as below code [ name, email....etc ], its not saving in folder path , looks like part of code is conflicting, i am really just started to learn php, so please kindly help me.
<?php
include 'home.php';
$userID = ""; //Initialization value; Examples
//"" When you want to append stuff later
//0 When you want to add numbers later
//isset()
$userID = isset($_POST['userID']) ? $_POST['userID'] : '';
//empty()
$userID = !empty($_POST['userID']) ? $_POST['userID'] : '';
// session_start();
require_once 'class.user.php';
$user_home = new USER();
if (!$user_home->is_logged_in()) {
header("Location: index.php");
die();
}
$stmt = $user_home->runQuery("SELECT * FROM tbl_users WHERE userID=:uid");
$stmt->execute(array(":uid" => $_SESSION['userSession']));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
?>
<?php
/* php codde */
$FORM['uname'] = "";
$FORM['txtuname'] = "";
if (isset($_POST['submit'])) {
// new data
$uname = $_POST['txtuname'];
$email = $_POST['txtemail'];
$phone = $_POST['phone'];
$street_address = $_POST['street_address'];
$street_address_2 = trim($_POST['street_address_2']);
$city = trim($_POST['city']);
$state = trim($_POST['state']);
$zip_code = trim($_POST['zip_code']);
$country = trim($_POST['country']);
$sold_by = trim($_POST['sold_by']);
$portfolio = trim($_POST['portfolio']);
$paypal_email_id = trim($_POST['paypal_email_id']);
$account_holder_name = trim($_POST['account_holder_name']);
$account_number = trim($_POST['account_number']);
$branch_name = trim($_POST['branch_name']);
$bank_name = trim($_POST['bank_name']);
$ifsc_code = trim($_POST['ifsc_code']);
$uid = (isset($_GET['userID']) ? intval($_GET['userID']) : -1);
// query
if ($user_home->update($uname, $email, $phone, $street_address, $street_address_2, $city, $state, $zip_code, $country, $sold_by, $portfolio, $paypal_email_id, $account_holder_name, $account_number, $branch_name, $bank_name, $ifsc_code, $uid))
; {
header("Location: profile.php");
die();
}
}
/* php codde end */
?>
<!DOCTYPE html>
<html class="no-js">
<h2> Welcome to profile page</h2>
<head>
<title><?php echo $row['userEmail']; ?></title>
<title><?php echo $row['userEmail']; ?></title>
<!-- Bootstrap -->
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
<link href="assets/styles.css" rel="stylesheet" media="screen">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<form action="profile1.php" method="POST" enctype="multipart/form-data">
<h3>Personal details</h3>
Name :
<input type="text" name="txtuname" value="<?php echo $row['userName'] ?>" /><br/>
Email :
<input type="text" name="txtemail" value="<?php echo $row['userEmail'] ?>" /><br>
Sold_by :
<input type="text" name="sold_by" value="<?php echo $row['sold_by'] ?>" /><br/>
Portfolio :
<input type="text" name="portfolio" value="<?php echo $row['portfolio'] ?>" /><br>
<h3>ADDRESS</h3>
Phone :
<input type="text" name="phone" value="<?php echo $row['phone'] ?>" /><br>
street address :
<input type="text" name="street_address" value="<?php echo $row['street_address'] ?>" /><br>
street address 2 :
<input type="text" name="street_address_2" value="<?php echo $row['street_address_2'] ?>" /><br>
city :
<input type="text" name="city" value="<?php echo $row['city'] ?>" /><br>
state :
<input type="text" name="state" value="<?php echo $row['state'] ?>" /><br>
country :
<input type="text" name="country" value="<?php echo $row['country'] ?>" /><br>
zip :
<input type="text" name="zip_code" value="<?php echo $row['zip_code'] ?>" /><br>
<h3>Payment details</h3>
<input type="text" name="paypal_email_id" value="<?php echo $row['paypal_email_id'] ?>" /><br>
<h4>Wiretransfer </h4><br/>
Account holder name :
<input type="text" name="account_holder_name" value="<?php echo $row['account_holder_name'] ?>" /><br>
account number :
<input type="text" name="account_number" value="<?php echo $row['account_number'] ?>" /><br>
Branch name :
<input type="text" name="branch_name" value="<?php echo $row['branch_name'] ?>" /><br>
Bank name :
<input type="text" name="bank_name" value="<?php echo $row['bank_name'] ?>" /><br>
IFSC CODE :
<input type="text" name="ifsc_code" value="<?php echo $row['ifsc_code'] ?>" /><br>
<h3>Other information : </h3>
<h2>Upload File</h2>
<label for="fileSelect">Filename1:</label>
<input type="file" name="photo" id="fileSelect"><br>
<input type="submit" name="submit" value="Save" />
</form>
</html>
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
</html>
<?php
if (isset($_FILES["photo"]["error"])) {
if ($_FILES["photo"]["error"] > 0) {
echo "Error: " . $_FILES["photo"]["error"] . "<br>";
} else {
$allowed = array("jpg" => "image/jpg", "jpeg" => "image/jpeg", "gif" => "image/gif", "png" => "image/png");
$filename = $_FILES["photo"]["name"];
$filetype = $_FILES["photo"]["type"];
$filesize = $_FILES["photo"]["size"];
// Verify file extension
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if (!array_key_exists($ext, $allowed))
die("Error: Please select a valid file format.");
// Verify file size - 5MB maximum
$maxsize = 5 * 1024 * 1024;
if ($filesize > $maxsize)
die("Error: File size is larger than the allowed limit.");
// Verify MYME type of the file
if (in_array($filetype, $allowed)) {
// Check whether file exists before uploading it
if (file_exists("upload/" . $_FILES["photo"]["name"])) {
echo $_FILES["photo"]["name"] . " is already exists.";
} else {
move_uploaded_file($_FILES["photo"]["tmp_name"], "upload/" . $_FILES["photo"]["name"]);
echo "Your file was uploaded successfully.";
}
} else {
echo "Error: There was a problem uploading your file - please try again.";
}
}
} else {
echo "Error: Invalid parameters - please contact your server administrator.";
}
?>
when i remove below code from above page, image is uploading fine, i tried to remove lot of code and make it short, so that its going to be helpfull for readers to solve issue easily, but i end up in getting lot of different kinds of errors, so i posted full code, i am extremely sorry for that....
<?php
/* php codde */
$FORM['uname'] = "";
$FORM['txtuname'] = "";
if (isset($_POST['submit'])) {
// new data
$uname = $_POST['txtuname'];
$email = $_POST['txtemail'];
$phone = $_POST['phone'];
$street_address = $_POST['street_address'];
$street_address_2 = trim($_POST['street_address_2']);
$city = trim($_POST['city']);
$state = trim($_POST['state']);
$zip_code = trim($_POST['zip_code']);
$country = trim($_POST['country']);
$sold_by = trim($_POST['sold_by']);
$portfolio = trim($_POST['portfolio']);
$paypal_email_id = trim($_POST['paypal_email_id']);
$account_holder_name = trim($_POST['account_holder_name']);
$account_number = trim($_POST['account_number']);
$branch_name = trim($_POST['branch_name']);
$bank_name = trim($_POST['bank_name']);
$ifsc_code = trim($_POST['ifsc_code']);
$uid = (isset($_GET['userID']) ? intval($_GET['userID']) : -1);
// query
if ($user_home->update($uname, $email, $phone, $street_address, $street_address_2, $city, $state, $zip_code, $country, $sold_by, $portfolio, $paypal_email_id, $account_holder_name, $account_number, $branch_name, $bank_name, $ifsc_code, $uid))
; {
header("Location: profile.php");
die();
}
}
/* php codde end */
?>
This is not going to do what you expect as there is a ; in the wrong place here
// query
if ($user_home->update($uname, $email, $phone, $street_address, $street_address_2, $city, $state, $zip_code, $country, $sold_by, $portfolio, $paypal_email_id, $account_holder_name, $account_number, $branch_name, $bank_name, $ifsc_code, $uid))
; // <-- remove this
{
header("Location: profile.php");
die();
}
I have just made a profile page in PHP for a user which displays user profile information including their picture, The image is stored on the database and everytime when I upload an image on the web page, the database does work and update the database profile section but it is not showing on the web browser. :/ i tried different browsers but every browser failed to display the image, the Alt parameter of image does show but no image, i have inspected the page element the image path is there but i can't see the image there?
the code in the profile page is:
<?php
function change_profile_image($userID, $file_temp, $file_extn) {
$file_path ='C:/xampp/htdocs/cricket/user/images/profile/'. substr(md5(time()), 0, 10) . '.' . $file_extn;
move_uploaded_file($file_temp, $file_path);
mysql_query("UPDATE `user` SET `profile` = '" . mysql_real_escape_string($file_path) . "' WHERE `userID` = " . (int)$userID);
}
?>
<?php
$query = "select * from user where userID='".$_SESSION['id']."'";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result)
?>
<link rel="stylesheet" type="text/css" href="../css/style.css">
<div id="content">
<h1>Edit Your Information</h1>
<div class="profile">
<?php
if (isset($_FILES['profile'])=== true) {
if (empty($_FILES['profile']['name']) === true) {
echo "Please choose a file!";
} else {
$allowed = array('jpg', 'jpeg', 'gif', 'png');
$file_name = $_FILES['profile']['name'];
$file_extn = strtolower(end(explode('.', $file_name)));
$file_temp = $_FILES['profile']['tmp_name'];
if (in_array($file_extn, $allowed)=== true) {
change_profile_image($_SESSION['id'], $file_temp, $file_extn);
} else {
echo "incorrect file type, Allowed: ";
echo implode(', ', $allowed);
}
}
}
if (empty($row['profile']) === false) {
echo '<img src="', $row['profile'], '" alt="', $row['user_firstname'], '\'s Profile Image">';
}
?>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="profile"> <br> <input type="submit">
</form>
</div>
<form method="post" action="">
<div class="txtbox1">Email</div>
<div class="txtbox">
<input type="text" name="email" value="<?php echo $row['user_email']?>"> </div><br><br><br>
<div class="txtbox1">First Name</div>
<div class="txtbox">
<input type="text" name="firstname" value="<?php echo $row['user_firstname']?>"></div><br><br><br>
<div class="txtbox1">Surname</div>
<div class="txtbox">
<input type="text" name="lastname" value="<?php echo $row['user_surname']?>"></div><br><br><br>
<div class="txtbox1">DOB</div>
<div class="txtbox">
<input type="text" name="dob" value="<?php echo $row['user_dob']?>"></div><br>
<div class="txtbox"><input type="submit" value="update" name="update"> </div>
</form>
<?php
if(isset($_POST['update'])){
$query1 = "update user set user_email='".$_POST['email']."', user_firstname='".$_POST['firstname']."', user_surname='".$_POST['lastname']."', user_dob='".$_POST['dob']."' where userID='".$_SESSION['id']."'";
$result1 = mysql_query($query1);
echo "<script>alert('Your Information has been changed SuccessFully..'); window.location = './edit.php';</script>";
}
?>
</div>
If anyone is interested in the CSS the styling code is:
.profile {
background:white;
border:1px dashed #ccc;
padding:5px;
}
.profile img {
width=100%;
}
i will really appreciate if anyone can guide me or help me in the right direction
The image is stored on the database and everytime when I upload an image on the web page, the database does work and update the database profile section but it is not showing on the web browser. :/ i tried different browsers but every browser failed to display the image, the Alt parameter of image does show but no image, i have inspected the page element the image path is there but i can't see the image there?
the code in the profile page is:
<?php
function change_profile_image($userID, $file_temp, $file_extn) {
$file_path ='C:/xampp/htdocs/cricket/user/images/profile/'. substr(md5(time()), 0, 10) . '.' . $file_extn;
move_uploaded_file($file_temp, $file_path);
mysql_query("UPDATE `user` SET `profile` = '" . mysql_real_escape_string($file_path) . "' WHERE `userID` = " . (int)$userID);
}
?>
<?php
$query = "select * from user where userID='".$_SESSION['id']."'";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result)
?>
<link rel="stylesheet" type="text/css" href="../css/style.css">
<div id="content">
<h1>Edit Your Information</h1>
<div class="profile">
<?php
if (isset($_FILES['profile'])=== true) {
if (empty($_FILES['profile']['name']) === true) {
echo "Please choose a file!";
} else {
$allowed = array('jpg', 'jpeg', 'gif', 'png');
$file_name = $_FILES['profile']['name'];
$file_extn = strtolower(end(explode('.', $file_name)));
$file_temp = $_FILES['profile']['tmp_name'];
if (in_array($file_extn, $allowed)=== true) {
change_profile_image($_SESSION['id'], $file_temp, $file_extn);
} else {
echo "incorrect file type, Allowed: ";
echo implode(', ', $allowed);
}
}
}
if (empty($row['profile']) === false) {
echo '<img src="', $row['profile'], '" alt="', $row['user_firstname'], '\'s Profile Image">';
}
?>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="profile"> <br> <input type="submit">
</form>
</div>
<form method="post" action="">
<div class="txtbox1">Email</div>
<div class="txtbox">
<input type="text" name="email" value="<?php echo $row['user_email']?>"> </div><br><br><br>
<div class="txtbox1">First Name</div>
<div class="txtbox">
<input type="text" name="firstname" value="<?php echo $row['user_firstname']?>"></div><br><br><br>
<div class="txtbox1">Surname</div>
<div class="txtbox">
<input type="text" name="lastname" value="<?php echo $row['user_surname']?>"></div><br><br><br>
<div class="txtbox1">DOB</div>
<div class="txtbox">
<input type="text" name="dob" value="<?php echo $row['user_dob']?>"></div><br>
<div class="txtbox"><input type="submit" value="update" name="update"> </div>
</form>
<?php
if(isset($_POST['update'])){
$query1 = "update user set user_email='".$_POST['email']."', user_firstname='".$_POST['firstname']."', user_surname='".$_POST['lastname']."', user_dob='".$_POST['dob']."' where userID='".$_SESSION['id']."'";
$result1 = mysql_query($query1);
echo "<script>alert('Your Information has been changed SuccessFully..'); window.location = './edit.php';</script>";
}
?>
</div>
If anyone is interested in the CSS the styling code is:
.profile {
background:white;
border:1px dashed #ccc;
padding:5px;
}
.profile img {
width=100%;
}
i will really appreciate if anyone can guide me or help me in the right direction
I am trying to combine multiple form elements. I have 2 buttons, 1 tex tbox and 1 upload box and 1 drop down menu as shown below:
So the user can select a directory where to upload, create a new one by clicking the 'Create' button and Upload files. However, with my current code, it does not work (files are uploaded to default directory).
This is the code:
<?php
include("login.php");
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>FileStore - Upload Files</title>
<link rel="stylesheet" href="./CSS/style.css" type="text/css" media="screen, projection" />
</head>
<body>
<div id="wrapper">
<header id="header">
<div id="header-content">
<strong><h1>FileStore</h1></strong> Upload multiple files at once!
</div>
<div class="login-info" >
<?php
if ($isLoggedin === false) {
echo ' <form action="" method="POST">
Username: <input name="username" >
Password: <input type="password" name="password" size="8">
<input type="submit" name="submit" value="Login">
</form>';
echo "<p align='right'>You are not logged in.</p>";
echo "<b><a href='registration.php'>Register</a></b>";
}else{
echo $welcomeMsg;
}
?>
</div>
</header><!-- #header-->
<section id="middle" align="center">
<div id="container">
<br><br>
<div id="content">
<strong><h1>Upload files</h1></strong><br><br>
<div id="upload-file" >
<form action="" method="post" enctype="multipart/form-data">
<input type="file" value="" name="upload[]" multiple>
<button type="submit">Upload!</button>
</form>
<select name="myDirs">
<option value="" selected="selected">Select a folder</option>
<?php
if (chdir("./files/" . $userid)) {
$dirs = glob('*', GLOB_ONLYDIR);
foreach($dirs as $val){
echo '<option value="'.$val.'">'.$val."</option>\n";
}
} else {
echo 'Changing directory failed.';
}
?>
<?php
include("dbConfig.php");
$Username = $_SESSION["username"];
global $userid;
$sql = "SELECT UserID FROM users WHERE Username = '".$Username."'";
$result = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_assoc($result)) {
$userid = $row['UserID'];
}
$newDir = $_REQUEST["newDir"];
$upload_dir = './files/' . (string)$userid . '/';
$folder_path = $upload_dir . "/" . $newDir . "/" ;
if (!file_exists($folder_path)) {
mkdir($folder_path, 0777, true);
chmod($folder_path, 0777);
echo "Folder" . $newDir . "created.";
echo "Redirecting to upload page..";
header( 'Location: ../upload.php' ) ;
} else {
echo "Error creating " . $newDir;
}
echo "<form action='' method='post'>";
echo "<input type='text' name='newDir'> ";
echo "<input type='submit' value='Create'>";
echo "</form>";
?>
<?php
include("dbConfig.php");
$Username = $_SESSION["username"];
global $userid;
global $up_path;
$error_message[0] = "Unknown problem with upload.";
$error_message[1] = "Uploaded file too large (load_max_filesize).";
$error_message[2] = "Uploaded file too large (MAX_FILE_SIZE).";
$error_message[3] = "File was only partially uploaded.";
$error_message[4] = "Choose a file to upload.";
$sql = "SELECT UserID FROM users WHERE Username = '".$Username."'";
$result = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_assoc($result)) {
$userid = $row['UserID'];
}
$vpath = strlen($userid);
$upload_dir = './files/' . (string)$userid . '/';
$num_files = count($_FILES['upload']['name']);
if (!file_exists($upload_dir)) {
mkdir($upload_dir, 0777, true);
chmod($upload_dir, 0777);
} else {
for ($i=0; $i < $num_files; $i++) {
$upload_file = $upload_dir . urlencode(basename($_FILES['upload']['name'][$i]));
if (#is_uploaded_file($_FILES['upload']['tmp_name'][$i])) {
if (#move_uploaded_file($_FILES['upload']['tmp_name'][$i],
$upload_file)) {
/* Great success... */
echo basename($upload_file) . " has been uploaded. <br>";
//$content = file_get_contents($upload_file);
//echo $content;
} else {
print $error_message[$_FILES['upload']['error'][$i]];
}
} else {
print $error_message[$_FILES['upload']['error'][$i]];
}
}
}
?>
</div>
</div><!-- #content-->
</div><!-- #container-->
<aside id="sideLeft">
<div id="menu-x" align="center"><br>
<strong>Menu</strong><br><br>
<div class="menu">
<ul>
<li>Home</li>
<li>Upload</li>
<li>Files</li>
<li>About</li>
<li>Help</li>
<li>Logout</li>
</ul>
<br style="clear:left"/>
</div>
</div>
</aside><!-- #sideLeft -->
</section><!-- #middle-->
<footer id="footer">
<strong>FileStore:</strong> A CMT 3315 Project by Brian Livori
</footer><!-- #footer -->
</div><!-- #wrapper -->
</body>
</html>
I wan to enable the user to create a directory before uploading, and then choose a directory to upload by selecting an option from the drop down.
How can I do this?
Your form tag ends before select box so move it below select box and you should get your post values related to chosen upload dir.
i have this page for upload:
<?php
require ('incs/db.php');
require_once ('incs/funcs.php');
?>
<?php
if (array_key_exists('upload', $_POST)) {
$directory = str_replace(basename($_SERVER['PHP_SELF']),'',$_SERVER['PHP_SELF']);
$uploadHandler = $_SERVER['DOCUMENT_ROOT']. $directory . 'images/';
// $uploadHandler = "echtitipi".$_SERVER['HTTP_HOST']. '/images/';
$max_file_size = 30000;
define('UPLOAD_DIR', $uploadHandler);
$ext= end(explode(".", $_FILES['image']['name']));
$name = rand(1111111,9999999).'.'.$ext;
if (move_uploaded_file($_FILES['image']['tmp_name'], $uploadHandler. $name))
{
$upload = true;
$title = $_POST ['title'];
$sql = "INSERT INTO photo (id, keyword, photoName)
VALUES ('','$title','$name')
";
$result = mysql_query ( $sql, $con );
}
else
{
$upload = false;
$msg = 'Cant Upload!';
}
}
?>
<?php
include ('incs/header.php');
?>
<?php
getUrlQuery();
?>
<script language="javascript">
<!--
function pick(symbol, path) {
if (window.opener && !window.opener.closed)
window.opener.document.form.img.value = symbol;
window.opener.document.form.imgbox.src = path;
window.close();
}
// -->
</script>
<form action="upload.php" method="post" enctype="multipart/form-data" name="uploadImage" id="uploadImage">
<p>
<label for="image">
Tanım:
</label>
<input type="text" name="title" id="title" />
<label for="image">
Upload image:
</label>
<input type="file" name="image" id="image" />
</p>
<p>
<input type="submit" name="upload" id="upload" value="Upload" />
</p>
</form>
<?php
if($upload == true)
{
echo "<a hrf(because spam!)=\"javascript:pick('$name','images/$name')\"><im(g) src=\"images/$name\" border=\"0\" alt=\"use\"></a>";
}
?>
<?php
include ('incs/footer.php');
?>
`
this upload image to curretnt root's images folder. My current folder is admin:
root/admin/images
root/images
when i use
$uploadHandler = "http://".$_SERVER['HTTP_HOST']. '/images/';
script doesnot work.
<?php
if($upload == true)
{
echo "<a hrf=\"javascriptick('$name','{$uploadHandler}$name')\"><im(g) src=\"{$uploadHandler}$name\" border=\"0\" alt=\"use\"></a>";
}
?>
the image couldnot add to editor. I guess There is a problem with javascript.
what is wrong in script
echo "<a hrf=\"javascriptick('$name','{$uploadHandler}$name')\"><im(g) src=\"{$uploadHandler}$name\" border=\"0\" alt=\"use\"></a>";
change into
echo "<img src=\"{$uploadHandler}$name\" border=\"0\" alt=\"use\">";
I guess this will help...
Im sorry for bad dictation because i cant write the right script because sending errors(link and images)
above code uploaded code to
/www/admin/images
and save information to database and add image to tinymce editor. But I want to upload code to:
www/images
when I use :
$uploadHandler = $_SERVER['DOCUMENT_ROOT'].'/images/';
and
"<img src=\"images/$name\" border=\"0\" alt=\"use\">"
the image couldnot add to editor. This is my problem.