PHP - Notice: Only variables should be passed by reference in C:\xampp\htdocs\redsocial\gestionimagen.php

 
Vista:
Imágen de perfil de Cristian
Val: 26
Ha aumentado su posición en 5 puestos en PHP (en relación al último mes)
Gráfica de PHP

Notice: Only variables should be passed by reference in C:\xampp\htdocs\redsocial\gestionimagen.php

Publicado por Cristian (14 intervenciones) el 16/01/2018 18:10:47
Buen día,
Es que me sale este error a la hora de subir una imagen que no corresponda a JPG me muestra este error:
Notice: Only variables should be passed by reference in C:\xampp\htdocs\redsocial\gestionimagen.php on line 17

Este es mi código:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
if (!isset($_SESSION)) {
  session_start();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Subir Imagen</title>
</head>
 
<body>
 
<?php if ((isset($_POST["enviado"])) && ($_POST["enviado"] == "form1")) {
 
	if (($_FILES['userfile']['size']>102400) || (end(explode(".", $_FILES['userfile']['name']))!="jpg"))
		echo "Solo ficheros de 100Kb como maximo y con extension .jpg";
		else
	{
	$nombre_archivo = $_FILES['userfile']['name'];
	move_uploaded_file($_FILES['userfile']['tmp_name'], "images/usuarios/".$_SESSION['MM_UsuarioRedSocial'].".jpg");
 
	?>
    <script>
		opener.document.form1.strImagen.value="<?php echo $nombre_archivo; ?>";
		self.close();
	</script>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de italo
Val: 920
Bronce
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Notice: Only variables should be passed by reference in C:\xampp\htdocs\redsocial\gestionimagen.php

Publicado por italo (150 intervenciones) el 16/01/2018 22:02:54
hola, prueba asi:

1
2
3
4
5
6
$file_name = $_FILES[$userfile]['name'];
 
$tmp = explode('.', $file_name);
$file_extension = end($tmp);
 
if (($_FILES['userfile']['size']>102400) || ($file_extension != "jpg"))

http://php.net/manual/es/function.end.php

ojo:

|| = OR
&& = AND



salud2
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
Imágen de perfil de Cristian
Val: 26
Ha aumentado su posición en 5 puestos en PHP (en relación al último mes)
Gráfica de PHP

Notice: Only variables should be passed by reference in C:\xampp\htdocs\redsocial\gestionimagen.php

Publicado por Cristian (14 intervenciones) el 18/01/2018 20:04:01
Muchas gracias
fue de gran ayuda!!!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar