Jump to content

output image


patelp7

Recommended Posts

I  am having difficulties in uploading a image if a user attaches a image.

It will go through the upload process, but will not display the image.

 

Can someone please help? Been stuck for days!!

 

function DisplayAddForm ($errorstring) {
print ('<html>
<head></head>
<body>
<H3>Create Bulletin</H3>
<P>Please enter Todays log</p>
');
echo $errorstring;
print('
<form action="AddBulletin.php" method=post>
<label><br /><br />
Subject
<input name="Subject"  type="text" id="Subject" size="100" />
<input type="hidden" name="fname"  value="<?=$flname?>" >
<br /><br />Description 
<textarea name="Description" cols="100" rows="8" id="Description"></textarea>
<br />
<br />Dr Comments 
<textarea name="Drcomments" cols="100" rows="2" id="Drcomments"></textarea>
</label>
<p> </p>
<p><img src="Pictures/<?=$flname?>" width="100" height="100"></p>
<br><Input type =SUBMIT name ="SUBMIT" value="SUBMIT">
<Input type = Reset>
</form>
<form  method=post enctype="multipart/form-data">
  	<input type="hidden" name="MAX_FILE_SIZE" value="300000" />
         <input name="userfile" type="file" class="inputbox-boder" size="20">
	<input name="subfile" type="submit" value="Upload">
</form>
</body>
</html>
');
}

Link to comment
Share on other sites

<?
session_start();
require ("db.php.inc");
require ("addBulletinfunc.inc");
require("authenticateadmin.inc");


//lines 4 to 15 uploads a picture for the product.  this picture can be located from anywhere within the computers hard drive. 
$flname="";
if (isset($_POST['subfile'])){
$flname = basename($_FILES['userfile']['name']);
$flname = str_replace(" ","",$flname);
$uploaddir = "Pictures/";
$uploadfile = $uploaddir . $flname;
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
} 
else {
   		echo "Possible file upload attack!\n";
}
}


$Userlevel=0;
$fname=$_POST['fname'];

if (isset($_POST['SUBMIT']) ){
extract($_POST);
$error=1;


//check to see variables are set
if ( (isset($Subject)) && (isset($Description)) && (isset($Drcomments)) ) {




//set error flag to 0
$error=0;


//Remove leading and trailing white spaces in input
$Subject=trim($Subject);
$Description=trim($Description);


//check to see if username and password contain sufficient characters

$Subjectlen = strlen($Subject);
$Desclen= strlen($Description);




If ( (($Subjectlen>2) && ($Desclen>2)) ){



//palis shit up to here.
$query = "insert into bulletin (Subject, Description, DrComments, Adminusername, Datecreated, Image) Values ('$Subject', '$Description',
'$Drcomments', '".$_SESSION['Username']."', NOW(), '$fname')";

$result=mysql_query($query);



if (mysql_errno()<>0) {
$error =1;
$errorstring = mysql_error() . "\n";
}
}else{
$error=1;
}
if(($Subjectlen<0)){
$errorstring.="<BR>Your name was $Subjectlen characters long it must be more than 1 character long.<BR>";
}

if (($Desclen<0)){
$errorstring .= "<BR> Your Supplier was $Descriptionlen characters long in must be above 0. <BR>";
}
}
if ($error<>0){
DisplayAddForm($errorstring);
}else{
$Username=$_session['Username'];
$Userlevel= $_session['Userlevel'];
DisplayMenu($Username, $Userlevel, "Bulletin added sucessfully");
}
}else{
DisplayAddForm($errorstring);

}
?>

Link to comment
Share on other sites

<?
session_start();
require ("db.php.inc");
require ("addBulletinfunc.inc");
require("authenticateadmin.inc");


//lines 4 to 15 uploads a picture for the product.  this picture can be located from anywhere within the computers hard drive. 
$flname="";
if (isset($_POST['subfile'])){
$flname = basename($_FILES['userfile']['name']);
$flname = str_replace(" ","",$flname);
$uploaddir = "Pictures/";
$uploadfile = $uploaddir . $flname;
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
} 
else {
   		echo "Possible file upload attack!\n";
}
}


$Userlevel=0;
$fname=$_POST['fname'];

if (isset($_POST['SUBMIT']) ){
extract($_POST);
$error=1;


//check to see variables are set
if ( (isset($Subject)) && (isset($Description)) && (isset($Drcomments)) ) {




//set error flag to 0
$error=0;


//Remove leading and trailing white spaces in input
$Subject=trim($Subject);
$Description=trim($Description);


//check to see if username and password contain sufficient characters

$Subjectlen = strlen($Subject);
$Desclen= strlen($Description);




If ( (($Subjectlen>2) && ($Desclen>2)) ){



//palis shit up to here.
$query = "insert into bulletin (Subject, Description, DrComments, Adminusername, Datecreated, Image) Values ('$Subject', '$Description',
'$Drcomments', '".$_SESSION['Username']."', NOW(), '$fname')";

$result=mysql_query($query);

print '<img src="'.$uploadfile.'" />'; // edited here


if (mysql_errno()<>0) {
$error =1;
$errorstring = mysql_error() . "\n";
}
}else{
$error=1;
}
if(($Subjectlen<0)){
$errorstring.="<BR>Your name was $Subjectlen characters long it must be more than 1 character long.<BR>";
}

if (($Desclen<0)){
$errorstring .= "<BR> Your Supplier was $Descriptionlen characters long in must be above 0. <BR>";
}
}
if ($error<>0){
DisplayAddForm($errorstring);
}else{
$Username=$_session['Username'];
$Userlevel= $_session['Userlevel'];
DisplayMenu($Username, $Userlevel, "Bulletin added sucessfully");
}
}else{
DisplayAddForm($errorstring);

}
?>

 

added print '<img src="'.$uploadfile.'" />'; // edited here

 

after the insert, maybe that is what you want?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.