
Untitled
By: a guest on
Aug 9th, 2012 | syntax:
None | size: 0.96 KB | hits: 5 | expires: Never
<?php
session_start();
if (!isset($_SESSION['username']))
header("location:login.php");
$localfile = pathinfo($_FILES['image']['name']);
$type = explode("/", $_FILES['image']['type'], 2);
$connect = ftp_connect("ftp.engammalsko.frihost.org");
ftp_login($connect, "engammal", "******");
ftp_chdir($connect, "public_html/lss/images/members");
$list = ftp_nlist($connect, ".");
foreach ($list as $file)
{
if(preg_match("/{$_SESSION['username']}/", $file))
ftp_delete($connect, $file);
}
if ($type['0'] == "image")
ftp_put($connect, "{$_SESSION['username']}.{$localfile['extension']}", $_FILES['image']['tmp_name'], FTP_BINARY);
ftp_close($connect);
$mysqli = new mysqli("localhost", "engammal", "******", "engammal_lss");
if ($type['0'] == "image")
$query=$mysqli->query("UPDATE members SET img = '{$_SESSION['username']}.{$localfile['extension']}' WHERE username = '{$_SESSION['username']}'");
header("Location: avatar.php");
?>