我完全糊涂了,我有这个代码
<label for=<?php echo "img-input[".$n."]"; ?>>
<img id=<?php echo "img-pict[".$n."]"; ?> src=<?php echo "".$file[$n].""; ?> class="canvas-1">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[".$n."]"; ?>><strong><?php echo basename($file[$n]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[".$n."]"; ?> name=<?php echo "img-input[".$n."]"; ?>>
<input type="hidden" value=<?php echo "".$file[$n].""; ?> name=<?php echo "img-hidden[".$n."]"; ?> id=<?php echo "img-hidden[".$n."]";?>>
当我点击图像时,它会打开一个上传对话框,选择一个图像来替换给定的图像。这个Javascript代码
$('#img-frm input[type="file"]').change(function(){
// Get the input number
var str = this.id.split("[");
var i = str[1].substr(0,str[1].length-1);
var s = 'img-pict[' + i + ']';
// Get the new picture address
var new_img = window.URL.createObjectURL(this.files[0]);
// Preview the new picture
document.getElementById(s).src = new_img;
str = $(this).val().split("\\");
var n = str.length;
s = 'img-name[' + i + ']';
document.getElementById(s).innerHTML = str[n-1];
});
允许我实际更改我在对话框中选择的图像单击的图像。在此代码中,您可以看到我正在更改图像标记的src attribute
(下面的行只显示图像下的文件名)。第三,我有这个测试代码
<?php print_r($_FILES); ?>
问题是当我点击图片,更改图片并提交表单时,$ _FILES数组完全为空。请注意,初始图像是先前发布的表单的结果。我以为我两天前解决了这个问题,但它仍然会发生。我需要帮助!以下是所有代码
文件1
<?php
...
// Upload pictures
$folder = '../images/tmp';
foreach ($_FILES['files']['name'] as $i => $name){
if (strlen($_FILES['files']['name'][$i]) > 1 && (false !== strpos($_FILES['files']['type'][$i],'image'))){
if (!move_uploaded_file($_FILES['files']['tmp_name'][$i], $folder.'/'.$name)){
// Redirect to the Upload form
header('Location: osi_upload.php');
exit();
}
}
}
?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" type="image/x-icon" href="../images/favicon.ico">
<link rel="stylesheet" type="text/css" href="../css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="../css/preview.css">
<link rel="stylesheet" type="text/css" href="../css/font-awesome.css">
<link rel="stylesheet" type="text/css" href="../jquery-ui-smoothness/jquery-ui.css">
<script src="../js/jquery.js"></script>
<script src="../js/bootstrap.js"></script>
<script src="../js/npm.js"></script>
<script src="../jquery-ui-smoothness/jquery-ui.js"></script>
<script src="../js/osi_jquery.js"></script>
<title>OSi, Panafrican Photographer</title>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<header class="container">
<div class="col-xs-12 col-md-2"><a href="index.php"><img src="../images/osi_logo_white.png" alt="OSi" class="img-responsive center-block"></a></div>
<div class="text-uppercase col-xs-12 col-md-8 hide-sm">
<div class="text-center">african international photographer</div>
</div>
<div class="col-md-2 hide-sm"><img src="../images/afrique.png" alt="africa_white" class="img-responsive center-block"></div>
</header>
<section class="container no-pad-left-right">
<div class="col-xs-12 alert-info pad-top-bottom"><strong><?php echo $osi->clsdate($event_dte).' - '.$eventname_fr.': '; ?></strong><?php echo $post_fr; ?></div>
<div class="col-xs-12 alert-info pad-top-bottom"><strong><?php echo date('M d Y', strtotime($event_dte)).' - '.$eventname_en.': '; ?></strong><?php echo $post_en; ?></div>
<?php
$i = -1;
foreach(glob($folder.'/*') as $filename){
$file[++$i] = $filename;
} ?>
<form action="osi_upload_confirm.php" enctype="multipart/form-data" id="img-frm" method="post"><?php
// Medium and large devices
switch($gallery){
case 1:
{ ?>
<!--Canvas 1-->
<div class="col-xs-12 no-pad-left-right hide-sm"><?php
for($n=0;$n<=$i;$n++){ ?>
<div class="in-block">
<label for=<?php echo "img-input[".$n."]"; ?>>
<img id=<?php echo "img-pict[".$n."]"; ?> src=<?php echo "".$file[$n].""; ?> class="canvas-1">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[".$n."]"; ?>><strong><?php echo basename($file[$n]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[".$n."]"; ?> name=<?php echo "img-input[".$n."]"; ?>>
<input type="hidden" value=<?php echo "".$file[$n].""; ?> name=<?php echo "img-hidden[".$n."]"; ?> id=<?php echo "img-hidden[".$n."]";?>>
</div>
<?php
} ?>
</div><?php
break;
}
case 2:
{ ?>
<!--Canvas 2-->
<div class="col-md-3 no-pad-left-right hide-sm">
<div class="in-block">
<label for=<?php echo "img-input[0]"; ?>>
<img id=<?php echo "img-pict[0]" ?> src=<?php echo "".$file[0].""; ?> class="canvas-2">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[0]"; ?>><strong><?php echo basename($file[0]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[0]"; ?> name=<?php echo "img-input[0]"; ?>>
<input type="hidden" value=<?php echo "".$file[0].""; ?> name=<?php echo "img-hidden[0]"; ?>>
</div>
</div>
<div class="col-md-9 no-pad-left-right hide-sm"><?php
for($n=1;$n<=$i;$n++){ ?>
<div class="in-block">
<label for=<?php echo "img-input[".$n."]"; ?>>
<img id=<?php echo "img-pict[".$n."]"; ?> src=<?php echo "".$file[$n].""; ?> class="canvas-1">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[".$n."]"; ?>><strong><?php echo basename($file[$n]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[".$n."]"; ?> name=<?php echo "img-input[".$n."]"; ?>>
<input type="hidden" value=<?php echo "".$file[$n].""; ?> name=<?php echo "img-hidden[".$n."]"; ?>>
</div>
<?php
} ?>
</div><?php
break;
}
case 3:
{ ?>
<!--Canvas 3-->
<div class="col-md-3 no-pad-left-right hide-sm"><?php
foreach($arr=array(0,4) as $n){ ?>
<div class="in-block">
<label for=<?php echo "img-input[".$n."]"; ?>>
<img id=<?php echo "img-pict[".$n."]"; ?> src=<?php echo "".$file[$n].""; ?> class="canvas-1">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[".$n."]"; ?>><strong><?php echo basename($file[$n]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[".$n."]"; ?> name=<?php echo "img-input[".$n."]"; ?>>
<input type="hidden" value=<?php echo "".$file[$n].""; ?> name=<?php echo "img-hidden[".$n."]"; ?>>
</div>
<?php
} ?>
</div>
<div class="col-md-3 no-pad-left-right hide-sm">
<div class="in-block">
<label for=<?php echo "img-input[1]"; ?>>
<img id=<?php echo "img-pict[1]"; ?> src=<?php echo "".$file[1].""; ?> class="canvas-2">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[1]"; ?>><strong><?php echo basename($file[1]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[1]"; ?> name=<?php echo "img-input[1]"; ?>>
<input type="hidden" value=<?php echo "".$file[1].""; ?> name=<?php echo "img-hidden[1]"; ?>>
</div>
</div>
<div class="col-md-6 no-pad-left-right hide-sm"><?php
foreach($arr=array(2,3,5,6) as $n){ ?>
<div class="in-block">
<label for=<?php echo "img-input[".$n."]"; ?>>
<img id=<?php echo "img-pict[".$n."]"; ?> src=<?php echo "".$file[$n].""; ?> class="canvas-1">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[".$n."]"; ?>><strong><?php echo basename($file[$n]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[".$n."]"; ?> name=<?php echo "img-input[".$n."]"; ?>>
<input type="hidden" value=<?php echo "".$file[$n].""; ?> name=<?php echo "img-hidden[".$n."]"; ?>>
</div>
<?php
} ?>
</div><?php
break;
}
case 4:
{ ?>
<!--Canvas 4-->
<div class="col-md-6 no-pad-left-right hide-sm"><?php
foreach($arr=array(0,1,4,5) as $n){ ?>
<div class="in-block">
<label for=<?php echo "img-input[".$n."]"; ?>>
<img id=<?php echo "img-pict[".$n."]"; ?> src=<?php echo "".$file[$n].""; ?> class="canvas-1">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[".$n."]"; ?>><strong><?php echo basename($file[$n]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[".$n."]"; ?> name=<?php echo "img-input[".$n."]"; ?>>
<input type="hidden" value=<?php echo "".$file[$n].""; ?> name=<?php echo "img-hidden[".$n."]"; ?>>
</div>
<?php
} ?>
</div>
<div class="col-md-3 no-pad-left-right hide-sm">
<div class="in-block">
<label for=<?php echo "img-input[2]"; ?>>
<img id=<?php echo "img-pict[2]"; ?> src=<?php echo "".$file[2].""; ?> class="canvas-2">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[2]"; ?>><strong><?php echo basename($file[2]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[2]"; ?> name=<?php echo "img-input[2]"; ?>>
<input type="hidden" value=<?php echo "".$file[2].""; ?> name=<?php echo "img-hidden[2]"; ?>>
</div>
</div>
<div class="col-md-3 no-pad-left-right hide-sm"><?php
foreach($arr=array(3,6) as $n){ ?>
<div class="in-block">
<label for=<?php echo "img-input[".$n."]"; ?>>
<img id=<?php echo "img-pict[".$n."]"; ?> src=<?php echo "".$file[$n].""; ?> class="canvas-1">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[".$n."]"; ?>><strong><?php echo basename($file[$n]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[".$n."]"; ?> name=<?php echo "img-input[".$n."]"; ?>>
<input type="hidden" value=<?php echo "".$file[$n].""; ?> name=<?php echo "img-hidden[".$n."]"; ?>>
</div>
<?php
} ?>
</div><?php
break;
}
case 5:
{ ?>
<!--Canvas 5-->
<div class="col-md-9 no-pad-left-right hide-sm"><?php
foreach($arr=array(0,1,2,4,5,6) as $n){ ?>
<div class="in-block">
<label for=<?php echo "img-input[".$n."]"; ?>>
<img id=<?php echo "img-pict[".$n."]"; ?> src=<?php echo "".$file[$n].""; ?> class="canvas-1">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[".$n."]"; ?>><strong><?php echo basename($file[$n]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[".$n."]"; ?> name=<?php echo "img-input[".$n."]"; ?>>
<input type="hidden" value=<?php echo "".$file[$n].""; ?> name=<?php echo "img-hidden[".$n."]"; ?>>
</div>
<?php
} ?>
</div>
<div class="col-md-3 no-pad-left-right hide-sm">
<div class="in-block">
<label for=<?php echo "img-input[3]"; ?>>
<img id=<?php echo "img-pict[3]"; ?> src=<?php echo "".$file[3].""; ?> class="canvas-2">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[3]"; ?>><strong><?php echo basename($file[3]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[3]"; ?> name=<?php echo "img-input[3]"; ?>>
<input type="hidden" value=<?php echo "".$file[3].""; ?> name=<?php echo "img-hidden[3]"; ?>>
</div>
</div><?php
break;
}
case 6:
{ ?>
<!--Canvas 6-->
<div class="col-md-3 no-pad-left-right hide-sm">
<div class="in-block">
<label for=<?php echo "img-input[0]"; ?>>
<img id=<?php echo "img-pict[0]"; ?> src=<?php echo "".$file[0].""; ?> class="canvas-2">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[0]"; ?>><strong><?php echo basename($file[0]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[0]"; ?> name=<?php echo "img-input[0]"; ?>>
<input type="hidden" value=<?php echo "".$file[0].""; ?> name=<?php echo "img-hidden[0]"; ?>>
</div>
</div>
<div class="col-md-3 no-pad-left-right hide-sm"><?php
foreach($arr=array(1,4) as $n){ ?>
<div class="in-block">
<label for=<?php echo "img-input[".$n."]"; ?>>
<img id=<?php echo "img-pict[".$n."]"; ?> src=<?php echo "".$file[$n].""; ?> class="canvas-1">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[".$n."]"; ?>><strong><?php echo basename($file[$n]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[".$n."]"; ?> name=<?php echo "img-input[".$n."]"; ?>>
<input type="hidden" value=<?php echo "".$file[$n].""; ?> name=<?php echo "img-hidden[".$n."]"; ?>>
</div>
<?php
} ?>
</div>
<div class="col-md-3 no-pad-left-right hide-sm">
<div class="in-block">
<label for=<?php echo "img-input[2]"; ?>>
<img id=<?php echo "img-pict[2]"; ?> src=<?php echo "".$file[2].""; ?> class="canvas-2">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[2]"; ?>><strong><?php echo basename($file[2]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[2]"; ?> name=<?php echo "img-input[2]"; ?>>
<input type="hidden" value=<?php echo "".$file[2].""; ?> name=<?php echo "img-hidden[2]"; ?>>
</div>
</div>
<div class="col-md-3 no-pad-left-right hide-sm"><?php
foreach($arr=array(3,5) as $n){ ?>
<div class="in-block">
<label for=<?php echo "img-input[".$n."]"; ?>>
<img id=<?php echo "img-pict[".$n."]"; ?> src=<?php echo "".$file[$n].""; ?> class="canvas-1">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[".$n."]"; ?>><strong><?php echo basename($file[$n]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[".$n."]"; ?> name=<?php echo "img-input[".$n."]"; ?>>
<input type="hidden" value=<?php echo "".$file[$n].""; ?> name=<?php echo "img-hidden[".$n."]"; ?>>
</div>
<?php
} ?>
</div><?php
break;
}
case 7:
{ ?>
<!--Canvas 7-->
<div class="col-md-3 no-pad-left-right hide-sm"><?php
foreach($arr=array(0,4) as $n){ ?>
<div class="in-block">
<label for=<?php echo "img-input[".$n."]"; ?>>
<img id=<?php echo "img-pict[".$n."]"; ?> src=<?php echo "".$file[$n].""; ?> class="canvas-1">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[".$n."]"; ?>><strong><?php echo basename($file[$n]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[".$n."]"; ?> name=<?php echo "img-input[".$n."]"; ?>>
<input type="hidden" value=<?php echo "".$file[$n].""; ?> name=<?php echo "img-hidden[".$n."]"; ?>>
</div>
<?php
} ?>
</div>
<div class="col-md-3 no-pad-left-right hide-sm">
<div class="in-block">
<label for=<?php echo "img-input[1]"; ?>>
<img id=<?php echo "img-pict[1]"; ?> src=<?php echo "".$file[1].""; ?> class="canvas-2">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[1]"; ?>><strong><?php echo basename($file[1]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[1]"; ?> name=<?php echo "img-input[1]"; ?>>
<input type="hidden" value=<?php echo "".$file[1].""; ?> name=<?php echo "img-hidden[1]"; ?>>
</div>
</div>
<div class="col-md-3 no-pad-left-right hide-sm"><?php
foreach($arr=array(2,5) as $n){ ?>
<div class="in-block">
<label for=<?php echo "img-input[".$n."]"; ?>>
<img id=<?php echo "img-pict[".$n."]"; ?> src=<?php echo "".$file[$n].""; ?> class="canvas-1">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[".$n."]"; ?>><strong><?php echo basename($file[$n]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[".$n."]"; ?> name=<?php echo "img-input[".$n."]"; ?>>
<input type="hidden" value=<?php echo "".$file[$n].""; ?> name=<?php echo "img-hidden[".$n."]"; ?>>
</div>
<?php
} ?>
</div>
<div class="col-md-3 no-pad-left-right hide-sm">
<div class="in-block">
<label for=<?php echo "img-input[3]"; ?>>
<img id=<?php echo "img-pict[3]"; ?> src=<?php echo "".$file[3].""; ?> class="canvas-2">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[3]"; ?>><strong><?php echo basename($file[3]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[3]"; ?> name=<?php echo "img-input[3]"; ?>>
<input type="hidden" value=<?php echo "".$file[3].""; ?> name=<?php echo "img-hidden[3]"; ?>>
</div>
</div><?php
break;
}
case 8:
{ ?>
<!--Canvas 8-->
<div class="col-md-3 no-pad-left-right hide-sm"><?php
foreach($arr=array(0,4) as $n){ ?>
<div class="in-block">
<label for=<?php echo "img-input[".$n."]"; ?>>
<img id=<?php echo "img-pict[".$n."]"; ?> src=<?php echo "".$file[$n].""; ?> class="canvas-1">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[".$n."]"; ?>><strong><?php echo basename($file[$n]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[".$n."]"; ?> name=<?php echo "img-input[".$n."]"; ?>>
<input type="hidden" value=<?php echo "".$file[$n].""; ?> name=<?php echo "img-hidden[".$n."]"; ?>>
</div>
<?php
} ?>
</div><?php
foreach($arr=array(1,2,3) as $n){ ?>
<div class="col-md-3 no-pad-left-right hide-sm">
<div class="in-block">
<label for=<?php echo "img-input[".$n."]"; ?>>
<img id=<?php echo "img-pict[".$n."]"; ?> src=<?php echo "".$file[$n].""; ?> class="canvas-2">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[".$n."]"; ?>><strong><?php echo basename($file[$n]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[".$n."]"; ?> name=<?php echo "img-input[".$n."]"; ?>>
<input type="hidden" value=<?php echo "".$file[$n].""; ?> name=<?php echo "img-hidden[".$n."]"; ?>>
</div>
</div><?php
}
break;
}
case 9:
{ ?>
<!--Canvas 9-->
<div class="col-xs-12 no-pad-left-right hide-sm"><?php
for($n=0;$n<=$i;$n++){ ?>
<div class="in-block">
<label for=<?php echo "img-input[".$n."]"; ?>>
<img id=<?php echo "img-pict[".$n."]"; ?> src=<?php echo "".$file[$n].""; ?> class="canvas-2">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[".$n."]"; ?>><strong><?php echo basename($file[$n]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[".$n."]"; ?> name=<?php echo "img-input[".$n."]"; ?>>
<input type="hidden" value=<?php echo "".$file[$n].""; ?> name=<?php echo "img-hidden[".$n."]"; ?>>
</div>
<?php
} ?>
</div><?php
break;
}
} ?>
<!--Extra small and small devices-->
<div class="col-xs-12 no-pad-left-right hide-md"><?php
for($n=0;$n<=$i;$n++){ ?>
<div class="in-block">
<label for=<?php echo "img-input[".$n."]"; ?>>
<img id=<?php echo "img-pict[".$n."]"; ?> src=<?php echo "".$file[$n].""; ?> class="canvas-1">
<div class="alert-success pad-top-bottom text-center" id=<?php echo "img-name[".$n."]"; ?>><strong><?php echo basename($file[$n]); ?></strong></div>
</label>
<input type="file" id=<?php echo "img-input[".$n."]"; ?> name=<?php echo "img-input[".$n."]"; ?>>
<input type="hidden" value=<?php echo "".$file[$n].""; ?> name=<?php echo "img-hidden[".$n."]"; ?>>
</div>
<?php
} ?>
</div>
<!--Updating form-->
<div class="col-xs-12 pad-top-bottom"></div>
<div class="form-group col-xs-12 col-md-6">
<label>Name of the new portfolio</label>
<input type="text" class="form-control input-sm" name="eventname_en" value=<?php echo "'".$eventname_en."'"; ?> required>
</div>
<div class="form-group col-xs-12 col-md-6">
<label>Nom du nouvel album</label>
<input type="text" class="form-control input-sm" name="eventname_fr" value=<?php echo "'".$eventname_fr."'"; ?> required>
</div>
<div class="form-group col-xs-12">
<label>Artist name/Nom de l'artiste</label>
<input type="text" class="form-control input-sm" name="artist" value=<?php echo "'".$artist."'"; ?> required>
</div>
<div class="form-group col-xs-12 col-md-6">
<label>Write the presentation text</label>
<textarea cols="53" rows="10" name="post_en" class="form-control form-except input-sm" required><?php echo $post_en; ?></textarea>
</div>
<div class="form-group col-xs-12 col-md-6">
<label>Entrer le texte de présentation</label>
<textarea cols="53" rows="10" name="post_fr" class="form-control form-except input-sm" required><?php echo $post_fr ?></textarea>
</div>
<div class="form-group col-xs-12">
<label>Select the gallery type/Selectionner le type de galérie</label>
<select name="gallery" class="form-control input-sm" required><?php
$n = $i + 1;
switch($n){
case 4:
{ ?>
<option value="0" <?php if($gallery==0) echo 'selected'; ?>>Gallery intro</option>
<option value="1" <?php if($gallery==1) echo 'selected'; ?>>Gallery type 01</option>
<option value="2" <?php if($gallery==2) echo 'selected'; ?>>Gallery type 02</option>
<option value="3" <?php if($gallery==3) echo 'selected'; ?>>Gallery type 03</option>
<option value="4" <?php if($gallery==4) echo 'selected'; ?>>Gallery type 04</option>
<option value="5" <?php if($gallery==5) echo 'selected'; ?>>Gallery type 05</option>
<option value="6" <?php if($gallery==6) echo 'selected'; ?>>Gallery type 06</option>
<option value="7" <?php if($gallery==7) echo 'selected'; ?>>Gallery type 07</option>
<option value="8" <?php if($gallery==8) echo 'selected'; ?>>Gallery type 08</option>
<option value="9" <?php if($gallery==9) echo 'selected'; ?>>Gallery type 09</option><?php
break;
}
case 5:
{ ?>
<option value="1" <?php if($gallery==1) echo 'selected'; ?>>Gallery type 01</option>
<option value="2" <?php if($gallery==2) echo 'selected'; ?>>Gallery type 02</option>
<option value="3" <?php if($gallery==3) echo 'selected'; ?>>Gallery type 03</option>
<option value="4" <?php if($gallery==4) echo 'selected'; ?>>Gallery type 04</option>
<option value="5" <?php if($gallery==5) echo 'selected'; ?>>Gallery type 05</option>
<option value="6" <?php if($gallery==6) echo 'selected'; ?>>Gallery type 06</option>
<option value="7" <?php if($gallery==7) echo 'selected'; ?>>Gallery type 07</option>
<option value="8" <?php if($gallery==8) echo 'selected'; ?>>Gallery type 08</option><?php
break;
}
case 6:
{ ?>
<option value="1" <?php if($gallery==1) echo 'selected'; ?>>Gallery type 01</option>
<option value="2" <?php if($gallery==2) echo 'selected'; ?>>Gallery type 02</option>
<option value="3" <?php if($gallery==3) echo 'selected'; ?>>Gallery type 03</option>
<option value="4" <?php if($gallery==4) echo 'selected'; ?>>Gallery type 04</option>
<option value="5" <?php if($gallery==5) echo 'selected'; ?>>Gallery type 05</option>
<option value="6" <?php if($gallery==6) echo 'selected'; ?>>Gallery type 06</option>
<option value="7" <?php if($gallery==7) echo 'selected'; ?>>Gallery type 07</option><?php
break;
}
case 7:
{ ?>
<option value="1" <?php if($gallery==1) echo 'selected'; ?>>Gallery type 01</option>
<option value="2" <?php if($gallery==2) echo 'selected'; ?>>Gallery type 02</option>
<option value="3" <?php if($gallery==3) echo 'selected'; ?>>Gallery type 03</option>
<option value="4" <?php if($gallery==4) echo 'selected'; ?>>Gallery type 04</option>
<option value="5" <?php if($gallery==5) echo 'selected'; ?>>Gallery type 05</option><?php
break;
}
case 8:
{ ?>
<option value="1" <?php if($gallery==1) echo 'selected'; ?>>Gallery type 01</option><?php
break;
}
} ?>
</select>
</div>
<div class="form-group col-xs-12">
<label>Name of the City/Nom de la ville</label>
<input type="text" class="form-control input-sm" name="city" value=<?php echo "'".$city."'"; ?> required>
</div>
<div class="form-group col-xs-12">
<label>Date de l'évènement/Event date</label>
<input type="date" class="form-control input-sm" name="event_dte" value=<?php echo "'".$event_dte."'"; ?> required>
<input type="hidden" name="photoid" value=<?php echo "'".$photoid."'"; ?>>
</div>
<div class="pull-right"><a href="osi_upload.php" class="btn btn-danger">Cancel</a> <button type="submit" class="btn btn-success">Submit</button></div>
</form>
</section>
</body>
</html>
文件2
// JavaScript Document
$(document).ready(function(){
// Change clicked pictures
if(!$('#img-frm input[type="file"]')){
return;
}
$('#img-frm input[type="file"]').change(function(){
// Get the input number
var str = this.id.split("[");
var i = str[1].substr(0,str[1].length-1);
var s = 'img-pict[' + i + ']';
// Get the new picture address
var new_img = window.URL.createObjectURL(this.files[0]);
// Preview the new picture
document.getElementById(s).src = new_img;
str = $(this).val().split("\\");
var n = str.length;
s = 'img-name[' + i + ']';
document.getElementById(s).innerHTML = str[n-1];
});
});
文件3
<?php
// Test $_FILES array
print_r($_FILES);
?>
我无法看到我搞砸的地方,图片的src attribute
会随着Javascript而改变,但表格会张贴空$_FILES array
。
答案 0 :(得分:0)
经过一些测试后,我意识到问题来自于不发送$_FILES
数据的HTML表单。
首先,<!---Extra small and small devices--->
代码覆盖//Medium and large device
数据,因为它们具有相同的变量名称,我使变量名称不同。
第二,连续divs
太多了。它似乎导致了形式的破坏,我不确定理解为什么?但我没有连续divs
的数据(或者我没有看到那里的实际问题)。但我更改了divs
的布局,现在我的表单完美无缺。
所以,有两个问题:php
变量名称和divs
布局。