prepare("SELECT hash, filename FROM files WHERE hash = (:hash)"); $do->bindParam(':hash', $filehash); $do->execute(); $result = $do->fetch(); if($result[0]==$filehash){ echo 'http://a.pomf.se/' . $result[1]; }else{ $newName = generate_name($_FILES['imagedata']['name']); $delid = sha1($_FILES['imagedata']['tmp_name']); //Insert info into DB $do = $con->prepare("INSERT INTO files (hash, orginalname, filename, size, date, expire, delid) VALUES (:hash, :orginname, :filename, :size, :date, :expire, :delid)"); $do->bindParam(':hash', $filehash); $do->bindParam(':orginname', $_FILES['imagedata']['name']); $do->bindParam(':filename', $newName); $do->bindParam(':size', $_FILES['imagedata']['size']); $do->bindParam(':date', date('Y-m-d')); $do->bindParam(':expire', $expire); $do->bindParam(':delid', $delid); $do->execute(); $hurr = '/mnt/disk1/pomf/files/' . $newName; move_uploaded_file($_FILES['imagedata']['tmp_name'], $hurr); echo 'http://a.pomf.se/' . $newName; } $con = null; } ?>