在此php中,我想获取一个“ ID”并从数据库中找到该ID的Img1。(Img1的URL存储在数据库中)。 然后删除此文件。但是img1并未删除
function delete(){
$connection = connectToDatabase();
$ID = $_REQUEST['ID'];
if($ID!==""){
$result1 = mysqli_query($connection,"select Img1 from banners where ID='$ID' ");
$row = mysqli_fetch_array($result1);
$namefile1 = $row[0];//(in $namefile1 the url address of img1 is saved like this:http://bestabsd.com/bestfile/pics/jan18-11-28-20-46-36.jpg)
$files = glob($namefile1);
foreach($files as $file){
if(is_file($file))
unlink($file);}
mysqli_close($connection);
}
答案 0 :(得分:0)
编辑:我将代码编辑为新代码以创建路径,但jpg尚未删除。...
#mainNav {
background-color: #212529;
}
#mainNav .navbar-toggler {
font-size: 12px;
right: 0;
padding: 13px;
text-transform: uppercase;
color: white;
border: 0;
background-color: #d6d6d6;
font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
}
#mainNav .navbar-brand image {
color: #fed136;
max-height: 100%;
}
font-family: 'Kaushan Script', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
}
#mainNav .navbar-brand.active, #mainNav .navbar-brand:active, #mainNav .navbar-brand:focus, #mainNav .navbar-brand:hover {
color: #fec503;
}
#mainNav .navbar-nav .nav-item .nav-link {
font-size: 90%;
font-weight: 400;
padding: 0.75em 0;
letter-spacing: 1px;
display: inline-block;
color: white;
font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
}
@media (min-width: 992px) {
#mainNav {
padding-top: 25px;
padding-bottom: 25px;
-webkit-transition: padding-top 0.3s, padding-bottom 0.3s;
transition: padding-top 0.3s, padding-bottom 0.3s;
border: none;
background-color: transparent;
}
#mainNav .navbar-brand {
font-size: 1.75em;
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
#mainNav .navbar-nav .nav-item .nav-link {
padding: 1.1em 1em !important;
border:2px solid transparent
}
#mainNav.navbar-shrink {
padding-top: 0;
padding-bottom: 0;
background-color: #222222;
}
#mainNav.navbar-shrink .navbar-brand {
font-size: 1.25em;
padding: 12px 0;
}
#mainNav .navbar-nav .nav-item .lang {
font-size:70%;
margin-top:10%
}
#mainNav .navbar-nav .nav-item input {
margin-top:4%;
text-align: center
}
}
label {
color:#ffffff
}
#mainNav .navbar-nav .nav-item .nav-link.active, #mainNav .navbar-nav .nav-item .nav-link:hover {
border-color: #fec503;
}
#mainNav .navbar-nav .nav-item .nav-link i {
color: #fed136;
margin-right:5px;
font-size:20px
}
header.masthead {
text-align: center;
color: #ffffff;
background-repeat: no-repeat;
background-attachment: scroll;
background-position: center center;
background-size: cover;
background-color:#222222;
-webkit-clip-path: polygon(0 0, 100% 0%, 100% 87%, 0 100%);
clip-path: polygon(0 0, 100% 0%, 100% 87%, 0 100%);
}
header.masthead .intro {
padding-top: 200px;
padding-bottom: 140px;
}
header.masthead .intro-text .intro-lead-in {
font-size: 22px;
font-style: italic;
line-height: 22px;
margin-bottom: 25px;
font-family: 'Droid Serif', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
}
header.masthead .intro-text .intro-heading {
font-size: 50px;
font-weight: 700;
line-height: 50px;
margin-bottom: 25px;
font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
}
@media (min-width: 768px) {
header.masthead .intro-text {
padding-top: 300px;
padding-bottom: 200px;
}
header.masthead .intro-text .intro-lead-in {
font-size: 40px;
font-style: italic;
line-height: 40px;
margin-bottom: 25px;
font-family: 'Droid Serif', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
}
header.masthead .intro-text .intro-heading {
font-size: 75px;
font-weight: 700;
line-height: 75px;
margin-bottom: 50px;
font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
}
}