是否可以修改查询中的值 $ value变量包含带有空格的上传文件名 我尝试在查询中修改代码中的值
foreach ($_FILES[photo][name] as $key => $value) {
// echo "ok";
if($value!="")
{
$image_path= 'API/Uploads/';
$building_images_0 = $value;
$building_images_0 = trim($building_images_0);
//also tried
$target0 = $image_path . $building_images_0;
move_uploaded_file($_FILES['photo']['tmp_name'][$key], $target0);
$query="update `tbl_site_attendace`
SET `employees_location`='".$_POST['comment']."',`no_of_worker`='".$_POST['zip']."',`image_".++$key."`='".$value."' where `id`= '".$_POST['atendance_id']."'";
$ update_query = $ conn-> query($ query);
但这不起作用。如何修改值以使其不应插入空格
答案 0 :(得分:0)
好的,我用str_replace
做到了 $new_value = str_replace(' ', '', $value);
$building_images_0 = $new_value;
$target0 = $image_path . $building_images_0;
move_uploaded_file($_FILES['photo']['tmp_name'][$key], $target0);
$query="update `tbl_site_attendace`
SET `employees_location`='".$_POST['comment']."',`no_of_worker`='".$_POST['zip']."',`image_".++$key."`='".$new_value."' where `id`= '".$_POST['atendance_id']."'";
$update_query= $conn->query($query);