Jump to content


Photo

Image Path Into Database


  • Please log in to reply
5 replies to this topic

#1 glenelkins

glenelkins
  • Members
  • PipPipPip
  • Advanced Member
  • 760 posts
  • LocationBridlington - East Riding of Yorkshire - United Kingdom

Posted 02 July 2006 - 03:26 PM

Quick couple of questions, using a file upload box on a form to upload an image...when the path is inserted into the database it misses the slashed (D:DocumentsFolderFolderFile.jpg) why??

Second, when i then take this value from the database, how do i display it back in the file upload box, this <input type="file" name="file" value="<? echo $valuefrom_db; ?>"> does not seem to display it

cheers
http://thewebsolutionprovider.com - A Solution For Everything Web!

#2 Drumminxx

Drumminxx
  • Members
  • PipPipPip
  • Advanced Member
  • 92 posts
  • LocationUSA

Posted 02 July 2006 - 04:13 PM

Quick couple of questions, using a file upload box on a form to upload an image...when the path is inserted into the database it misses the slashed (D:DocumentsFolderFolderFile.jpg) why??


post some code please.

Second, when i then take this value from the database, how do i display it back in the file upload box, this <input type="file" name="file" value="<? echo $valuefrom_db; ?>"> does not seem to display it


due to the way the file field works you can't set its value. your best bet is what I did just echo the name of the current file and right next to it give the user a file box to upload another file.
:: gucci.com ::
:: blockbuster.com ::

--------------------

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 02 July 2006 - 04:17 PM

my example ok



<? session_start();


if(!$userfile=="none"){

echo"No file specified<br><br><a href='members_upload_picture_form.php'>Please use this link</a>";
exit;
}

// check if user has a picture if so echo message and link

$db=mysql_connect("localhost" ,"xxx","xxx");

mysql_select_db("promotor",$db);



$query="select * from members_picture_uploads where name='$name' and id='$id'";

$result=mysql_query($query);

while($row=mysql_fetch_assoc($result)) {

if($row["userfile_name"]=1) {

echo "<b>sorry you have a picture already</b>";
echo"<br><br><a href='members_update_picture_form.php'>Please use this link</a>";
exit;
}
}

// file upload information

$uploaddir ="members_uploads/";

$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

//set a date sent

$date_sent=date("d-m-y");

// set a mime valadating

$blah = getimagesize($userfile);
$type = $blah['mime'];
$width = $blah[0];
$size = $blah[2]=$_FILES['userfile']['size'];



// valadate siz and type

if($size <= 50000) {

if($type) {

// if file correct let file throw and into the folder

if(move_uploaded_file($_FILES['userfile']['tmp_name'],$uploadfile)) {

$userfile_name=addslashes($userfile_name);

$query="insert into members_picture_uploads values('$id','$name','$date_sent','$userfile_name')";

$result=mysql_query($query);


// say thank you if the user has a valid file.

echo "file uploaded thank you<br>";
exit;
}

// echo link for valadating pic
}else{
echo "Wrong file type .jpg or .gif thank you <br><br> <a href ='members_upload_picture_form.php'>Pleae try agin</A>";
}

//echo link for valadating file size
}else{
echo "Wrong file size 50000 bytes only<br><br> <a href ='members_upload_picture_form.php'>Pleae try agin</A>";
}

?>
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 glenelkins

glenelkins
  • Members
  • PipPipPip
  • Advanced Member
  • 760 posts
  • LocationBridlington - East Riding of Yorkshire - United Kingdom

Posted 02 July 2006 - 04:21 PM

hi, thanks for the reply, here is some code that inserts the image filename, iv never had this problem before.

FIRST BIT CAPTURES THE USER ACTION (REGISTER) SECOND IS THE FUNCTION
/* REGISTER START */
if ($action == "register") {
  // Register
  if ($yourbest -> CheckRegPassMatch ($_POST['pword'],$_POST['rpword'])) {
    // Passwords fields match
    if ($reg = $yourbest -> Register ($_POST['fname'],$_POST['sname'],$_POST['title'],$_POST['comp'],$_POST['pno'],$_POST['email'],$_POST['uname'],$_POST['pword'],$_POST['image'])) {
      // Registration success
      $header_url = "Location: register_confirmation.php";
      header ($header_url);
      break;
    } else {
      // Registration failed
      echo $reg;
      break;
    }
  } else {
    // Passwords do not match
    $header_url = "Location: RegisterForm.php?message=The Password Fields Do Not Match!";
    header ($header_url);
    break;
  }
}
/* REGISTER END */
function Register ($fname,$sname,$title,$company,$phoneno,$email,$username,$password,$image) {
  $sql = "INSERT INTO users VALUES ('','$fname','$sname','$title','$company','$phoneno','$email','$username','$password','$image')";
  $result = mysql_query($sql);

  if ($result) {
    // Success
    return (true);
    break;
  } else {
    // Fail
    return (mysql_error());
    break;
  }
}
[code][/code]

http://thewebsolutionprovider.com - A Solution For Everything Web!

#5 glenelkins

glenelkins
  • Members
  • PipPipPip
  • Advanced Member
  • 760 posts
  • LocationBridlington - East Riding of Yorkshire - United Kingdom

Posted 02 July 2006 - 04:27 PM

I figured it! im such a dumb ass. Iv been putting the filename from the uplaod box into the database rather than the actual online path, due to the fact i have not included the image upload,resize function i have written!
http://thewebsolutionprovider.com - A Solution For Everything Web!

#6 Drumminxx

Drumminxx
  • Members
  • PipPipPip
  • Advanced Member
  • 92 posts
  • LocationUSA

Posted 02 July 2006 - 04:39 PM

::) it happens sometimes  :o
:: gucci.com ::
:: blockbuster.com ::

--------------------




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users