Jump to content
php.lv forumi

file_exists


ziedinjsh

Recommended Posts

kā lai izdzēš bildi no db?

 

Šādi es pievienoju bildi

if (isset($_POST['avatar'])){

$destination_path = "avatars/";

$result = 0;
$target_path = $destination_path . basename( $_FILES['avatar']['name']);
$avatar = basename($_FILES['avatar']['name']);

if($query = mysql_query("UPDATE users SET avatar='$avatar' WHERE email = '{$_SESSION['email']}'")) {
  move_uploaded_file($_FILES['avatar']['tmp_name'], $target_path);
     $result = 1;
  }

  sleep(1);

  echo "<script language='javascript' type='text/javascript'>window.top.window.stopUpload(".$result.");</script>";

}

bet kā izdzēst no db un foldera?

 

Sanāk vēl tagad tā

if (file_exists($avatar_file)) {
echo "<div class='avatar'><img src='avatars/".$row['avatar']."' width='200' height='200'></div>";
echo "<form method='post' action='".$_SERVER['PHP_SELF']."'>";
echo "<input type='submit' name='del_avatar' value='Delete'>";
echo "</form>";
}else{ 
echo "<form method='post' action='".$_SERVER['PHP_SELF']."' enctype='multipart/form-data' target='upload_target' onsubmit='startUpload();' >";
echo "<div id='loader-proces'><img src='misc/loader.gif' /></div>";                     
echo "<div id='form-proces'>";
echo "<input name='avatar' type='file' size='30' class='login-box'/><input type='submit' name='avatar' class='login-button' value='Upload' />";
echo "</div>";
echo "<iframe id='upload_target' name='upload_target' src='#' style='width:0;height:0;border:0px solid #fff;'></iframe>";                                        
echo "</form>";
}

Rādās bilde, bet kad viņu izdzēsu manuāli no db tad man neparādas upload forma kapēc ta?

Edited by ziedinjsh
Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...