ziedinjsh Posted April 2, 2010 Report Share Posted April 2, 2010 (edited) 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 April 2, 2010 by ziedinjsh Quote Link to comment Share on other sites More sharing options...
chizijs Posted April 2, 2010 Report Share Posted April 2, 2010 $avatar_file = "avatars/".$row['avatar'].""; .png, .jpg... nevajag? Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted April 2, 2010 Author Report Share Posted April 2, 2010 nevajag.. tas jau ir saglabājies ieks db, bildesnosaukums.jpg vai cits formāts $row['avatar'] ir jau tas bildesnosaukums.jpg Quote Link to comment Share on other sites More sharing options...
anonīms Posted April 3, 2010 Report Share Posted April 3, 2010 unlink Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.