File input no sé por qué no hace nada
Publicado por Jose (22 intervenciones) el 21/12/2017 13:04:20
Hola, Tengo un fichero upload y un fichero donde está el file input y no sé que pasa que no me da error pero no me va ni me reacciona. Qué puedo estar haciendo mal.
Ad.php
upload.php
Ad.php
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<?php
session_start();
//Validar que el usuario este logueado y exista un UID
if ( ! ($_SESSION['autenticado'] == 'SI' && isset($_SESSION['uid'])) )
{
//En caso de que el usuario no este autenticado, crear un formulario y redireccionar a la
//pantalla de login, enviando un codigo de error <form name="formulario" method="post" action="index.php">
?>
<form name="formulario" method="post" action="index.php">
<input type="hidden" name="msg_error" value="2">
</form>
<script type="text/javascript">
document.formulario.submit();
</script>
<?php
}
//Conectar BD
include("conectar_bd.php");
conectar_bd();
//Sacar datos del usuario que ha iniciado sesion"Propietario/a de ".$fila['Direccion']." ".$fila['PuertaLocalGaraje']
$sql = "SELECT tx_nombre tx_TipoUsuario,id_usuario, tx_username, tx_password
FROM tbl_users
LEFT JOIN ctg_tiposusuario
ON tbl_users.id_TipoUsuario = ctg_tiposusuario.id_TipoUsuario
WHERE id_usuario = '".$_SESSION['uid']."'";
$result =mysql_query($sql);
$nombreUsuario = "";
//Formar el nombre completo del usuario
if( $fila = mysql_fetch_array($result) ){
$nombreUsuario = "".$fila['tx_nombre'];
}
//Cerrrar conexion a la BD <td width="86" height="58"><a href="principal.php" target="_parent"><button style='width:100px; height:100px; cursor:pointer;' ><strong>Registro Visitas</strong></button> </a> </td>
//mysql_close($conexio);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Admi
</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Página Web exclusiva para clientes a</title>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/full-width-pics.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<script type="text/javascript">
<!--
$().ready(function() {
$("#frmlogin").validate();
$("#usuario").focus();
});
// -->
</script>
</head>
<body>
<!-- Navigation -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="principalcero.php" style="color:#FFF"> <?php setlocale(LC_ALL,"es_ES");
echo utf8_encode (strftime("%A %d de %B")); ?> </a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right" >
<li>
<a href="politicaprivacidad.php" style="color:#FFF" >Política de Privacidad</a>
</li>
<li>
<a href="normasdeuso.php" style="color:#FFF">Normas de Uso</a>
</li>
<li>
<a href="contacto.php" style="color:#FFF">Contacto</a>
</li>
<li align="right">
<a href="cerrarSesion.php" style="color:#FFF">Cerrar Sesión </a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
</div>
<!-- /.container -->
</nav>
<!-- Full Width Image Header with Logo -->
<!-- Image backgrounds are set within the full-width-pics.css file. -->
<header class="image-bg-fluid-height">
<img class="img-responsive img-center" src="img/fesmc.png" style='width:100px; height:85px;'
alt="">
</header>
<!-- Content Section -->
<section style="background-color:#E6E6FA; ">
<div class="container" style="background-color:#E6E6FA" margin: auto;>
<div class="row">
<div class="col-lg-12">
<h1 class="section-heading"
>Menú Principal</h1>
<br>
</br>
</div>
</div>
</div>
<div class="container" margin: auto; >
<div class="row">
<div class="col-lg-12 text-center">
<h3>Subir archivos con PHP</h3>
<form name="upload" method="post" action="?" enctype="multipart/form-data">
<div class="form-group">
<input type="file" name="archivo" id="archivo" class="form-control" required/>
</div>
<legend></legend>
<input type="submit" class="btn btn-primary center-block" name="subir" value="Subir" />
<br>
</form>
<?php
include_once("php/upload.php");
?>
<br>
<br><br><br>
</br>
</br>
</br>
</br>
</p>
<!-- Footer -->
<footer>
<div class="container">
<div class="row">
<div class="col-lg-12">Siempre cerca de tí</div>
<!-- /.row -->
</div>
</div>
</footer>
</section>
<!-- jQuery -->
<script src="js/jquery.js"></script>
<!-- Bootstrap Core javascript -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>
upload.php
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
if(isset($_POST["subir"]) && empty($_POST["archivo"])){
foreach ($_FILES["archivo"] as $archivo => $valor) {
}
$archivo=$_FILES["archivo"]["tmp_name"];
$destino="files/".$_FILES["archivo"]["name"];
if(($_FILES["archivo"]["type"]=="image/jpeg") || $_FILES["archivo"]["type"]=="image/png") && $_FILES["archivo"]["size"]<="2097152" ) ){
include_once("conexion2.php");
//CÔPIAMOS EL ARCHIVO AL DIRECTORIO
move_uploaded_file($archivo, $destino);
//insetamos en bd
$resul=@mysql_query("INSERT INTO `rutas`(`id`, `ruta`) VALUES (NULL,'$destino'); ") or die(mysql_error());
?>
<div class="alert alert-success form-group">
<strong>Archivo subido correctamente</strong>
</div>
<?php
}else{
?>
<div class="alert alert-warning">
<strong>solo se aceptan ficheros jpg o png con 2 mb máximo</strong>
<?php
}
}
?>
Valora esta pregunta


0