因此,該代碼是與實際好嗎「,「 或者 」。」 ,所以我想,這個問題必須在上傳文件或上傳照片並在服務器中創建的文件中的函數的PHP,是這樣的:
if(empty($_FILES['fotoperfil']['name']) === false){
$tipos = array('jpg','jpeg','gif','png');
$file_name = $_FILES['fotoperfil']['name'];
$file_ext = strtolower(end(explode('.', $file_name)));
$file_temp = $_FILES['fotoperfil']['tmp_name'];
$size = getimagesize($file_temp);
if($size[0] !== $size[1]){
$errors[]="Las fotos deben mantener la proporcion cuadrada establecido, por favor edita la foto en tu computador antes de subirla.";
} else if($size[0] > 400 or $size[1] > 400){
$errors[]="Las fotos pueden tener un tamaño maximo de 400 pixeles, puedes disminuir su tamaño en el computador y tratar de subirla denuevo";
}
if (in_array($file_ext, $tipos) === true){
if(empty($user_data['fotoperfil']) === false){
borrarfoto($user_data['userid'], $user_data['fotoperfil']);
}
cambiarfoto($user_data['idname'], $user_data['userid'], $file_temp, $file_ext);
}
和功能:
function cambiarfoto($name, $userid, $file, $ext){
$name = sanitize($name);
$file = sanitize($file);
$ext = sanitize($ext);
$file_path = 'img/perfiles/' . $name . '.' . $ext;
move_uploaded_file($file, $file_path);
mysql_query("UPDATE `usuarios` SET `fotoperfil` = '" . mysql_real_escape_string($file_path) . "' WHERE `userid` = " . (int)$userid);
}
當圖像被稱爲元素是這個樣子:
<img src="img/perfiles/ecangis.png" alt="Foto de perfil de Enzo" style="width:100px; height:100px;">
嗯,我改變了這一切,但沒有作出任何differense,只有改變PHP代碼的工作,這始終是如何工作沒有問題, t的位置他像被調用,問題是,瀏覽器不顯示@Ecangis你能告訴我發生什麼屏幕上的圖像本身 – Ecangis
當你運行我的代碼? – Ljubisa
類是善良的,不,其實是不正確的,因爲現在在我做你已經需要註冊看到這樣的,那麼,該頁面是在西班牙的網頁...讓我下班回家,變化然後發佈鏈接。 – Ecangis