我在更新时遇到move_uploaded_file问题。 所有行都会更新,除了行" p_photo"由于错误(not_shown) error_reporting返回none。有帮助吗?谢谢你的时间。
我有以下代码:
<?php
session_start();
include("../THISBD/thisbd.php");
error_reporting(E_ALL ^ E_NOTICE);
$logged_user = $_SESSION['this_user'];
$edit_session = $_SESSION['to_edit_p'];
$to_publish = 0;
$ruta = 0;
$p_photo = $_POST['p_photo_dialog_edit']);
$p_photo_name = $_FILES['p_photo_dialog_edit']['name']);
$p_photo_type = $_FILES['p_photo_dialog_edit']['type']);
$p_photo_temp = $_FILES['p_photo_dialog_edit']['tmp_name']);
var_dump($_FILES['p_photo_dialog_edit']['name']);
var_dump($_FILES['p_photo_dialog_edit']['type']);
var_dump($_FILES['p_photo_dialog_edit']['tmp_name']);
$publicacion = addslashes(htmlentities($_POST['to_publish']));
//Finds hastags
preg_match_all('/(#\w+)/', $publicacion, $matches);
foreach ($matches[0] as $hashtag){
$hashtags.=$hashtag;
}
$text_with_hashtags = preg_replace('/(#(\w+))/', '<a href="../search/?q=/\2">\1</a>', $publicacion);
$select_data_from_the_id = $all_conn->prepare("SELECT * FROM publicaciones WHERE id_comentario = :idcom");
$select_data_from_the_id->bindParam(":idcom", $edit_session);
$select_data_from_the_id->execute();
$fetch_selected_data = $select_data_from_the_id->fetch();
$got_from_user_p = $fetch_selected_data['from_user_p'];
$got_to_user_p = $fetch_selected_data['user'];
$got_foto = $fetch_selected_data['foto'];
$got_nombre = $fetch_selected_data['nombre'];
$got_text_to_edit = $to_publish;
$got_date = 'Enviado el: '.date('d').'/'.date('m').'/'.date('y').' a la(s): '.date('H').':'.date('i').':'.date('s');
$got_time = time();
$got_p_photo = $fetch_selected_data['p_photo'];
//Dock Photo
$dl_id1 = mt_rand(0, 9999999);
$dl_id2 = mt_rand(0, 9999999);
$dl_id3 = mt_rand(0, 9999999);
$dl_id4 = mt_rand(0, 9999999);
$dl_id5 = mt_rand(0, 9999999);
$dl_id6 = mt_rand(0, 9999999);
$dl_id7 = mt_rand(0, 9999999);
$dl_id8 = mt_rand(0, 9999999);
$dl_id9 = mt_rand(0, 9999999);
$dl_id10 = mt_rand(0, 9999999);
$dl_id11 = mt_rand(0, 9999999);
$delete_id = $dl_id1.$dl_id2.$dl_id3.$dl_id4.$dl_id5.$dl_id6.$dl_id7.$dl_id8.$dl_id9.$dl_id10.$dl_id11;
$n_status = 1;
$same_profile = 1;
$id1 = mt_rand(0, 9999999);
$id2 = mt_rand(0, 9999999);
$id3 = mt_rand(0, 9999999);
$id4 = mt_rand(0, 9999999);
$id5 = mt_rand(0, 9999999);
$id6 = mt_rand(0, 9999999);
$id7 = mt_rand(0, 9999999);
$id8 = mt_rand(0, 9999999);
$id9 = mt_rand(0, 9999999);
$id10 = mt_rand(0, 9999999);
$id11 = mt_rand(0, 9999999);
//Dck Photo conditionals
if ($p_photo_type === "image/jpeg"){$p_photo_type = ".jpg";
move_uploaded_file($p_photo_temp, "../media/".$id1.$id2.$id3.$id4.$id5.$id6.$id7.$id8.$id9.$id10.$id11.$p_photo_type);
$ruta = "../media/".$id1.$id2.$id3.$id4.$id5.$id6.$id7.$id8.$id9.$id10.$id11.$p_photo_type;}
if ($p_photo_type === "image/png"){$p_photo_type = ".png";
move_uploaded_file($p_photo_temp, "../media/".$id1.$id2.$id3.$id4.$id5.$id6.$id7.$id8.$id9.$id10.$id11.$p_photo_type);
$ruta = "../media/".$id1.$id2.$id3.$id4.$id5.$id6.$id7.$id8.$id9.$id10.$id11.$p_photo_type;}
if(strlen($publicacion) < 1 && strlen($ruta) < 1){return false;}
if((strlen($ruta) < 1) && $logged_user == $got_to_user_p){$n_status = 2; $same_profile = 2;}
if((strlen($ruta) > 1) && $logged_user == $got_to_user_p){$n_status = 2; $same_profile = 2;}
if(strlen($ruta) < 1){$ruta = $got_p_photo; $valid_photo = 1; $n_photo = "nophoto";}
if(strlen($ruta) >= 1){$valid_photo = 2; $n_photo = $ruta;}
$update_rows = $all_conn->prepare("UPDATE publicaciones SET from_user_p = ?, user = ?, foto = ?, nombre = ?, comentario = ?, `time` = ?, `date` = ?, p_photo = ?, to_delete = ?, same_profile = ?, valid_photo = ? WHERE id_comentario = ?");
$update_rows->bindParam("1", $got_from_user_p);
$update_rows->bindParam("2", $got_to_user_p);
$update_rows->bindParam("3", $got_foto);
$update_rows->bindParam("4", $got_nombre);
$update_rows->bindParam("5", $publicacion);
$update_rows->bindParam("6", $got_time);
$update_rows->bindParam("7", $got_date);
$update_rows->bindParam("8", $ruta);
$update_rows->bindParam("9", $delete_id);
$update_rows->bindParam("10", $same_profile);
$update_rows->bindParam("11", $valid_photo);
$update_rows->bindParam("12", $edit_session);
$update_rows->execute();
$delete_row_edit_p_photo_q = $all_conn->prepare("DELETE FROM edit_p_photo WHERE edit_from = :editfrom");
$delete_row_edit_p_photo_q->bindParam(":editfrom", $logged_user);
$delete_row_edit_p_photo_q->execute();
$insert_new_row_edit_p_photo = $all_conn->prepare("INSERT INTO edit_p_photo (edit_p_from, edit_p_photo_url) VALUES (?, ?)");
$insert_new_row_edit_p_photo->bindParam("1", $logged_user);
$insert_new_row_edit_p_photo->bindParam("2", $ruta);
$insert_new_row_edit_p_photo->execute();
?>
答案 0 :(得分:0)
您输入enctype =&#34; multipart / form-data&#34;在你的形式。如果是这样,请提供$ _FILES值。