Subir imagenes al servidor
Publicado por siREZ (203 intervenciones) el 05/09/2012 21:10:49
Cordial Saludo.
quiero subir imagenes al servidor y almacenarlas en una carpeta de nombre imagenes que he creado.
utilizo un formulario y luego un script PHP pero no me funciona.
Puede alguien ayudarme, o guiarme al respecto?
El formulario es el siguiente:
=======================================
el scrip que me debe levantar el archivo es:
=======================================
=====================================================
pero no hace nada.....
gracias por su ayuda.
siREZ
quiero subir imagenes al servidor y almacenarlas en una carpeta de nombre imagenes que he creado.
utilizo un formulario y luego un script PHP pero no me funciona.
Puede alguien ayudarme, o guiarme al respecto?
El formulario es el siguiente:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
$defecto = 'Eliga el archivo a subir y presione el boton Enviar!.';
$msg = ($_GET['errno']==1) ? $_GET['errmsg'] : $defecto;
?>
<form method="post" enctype="multipart/form-data" action="enviar.php">
<table width="50%" style="margin: auto;">
<tr>
<td colspan="2" style="width: 100%;"><b><?=$msg?></b></td>
</tr>
<tr>
<td style="width: 45%;">(1) Elegir Archivo:</td>
<td style="width: 55%;"><input type="file" name="archivo" size="20" /></td>
</tr>
<tr>
<td style="width: 45%;">(2) Enviar Archivo:</td>
<td style="width: 55%;"><label>
<input type="submit" name="button" id="button" value="Enviar" />
</label></td>
</tr>
</table>
</form>
=======================================
el scrip que me debe levantar el archivo es:
=======================================
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
<?php
# Nombre carpeta de archivos
$carpeta_archivos = 'imagenes';
# Maximo Bytes
$bytes_max = '5000';
# Si la carpeta no existe la creamos y le aplicamos los permisos.
if(!file_exists($carpeta_archivos))
{
mkdir($carpeta_archivos);
@chmod($carpeta_archivos, 0777);
}
# Verificamos que este setiado el archivo.
if($_FILES['archivo'])
{
# Verificamos que su tamaño sea mejor que los bytes que as puesto en la configuración.
if((1000 * $bytes_max) > $_FILES['archivo']['size'])
{
# Seteamos las variables para mejor facilidad
$tmp = $_FILES['archivo']['tmp_name'];
$name = $_FILES['archivo']['name'];
$ahora = $carpeta_archivos.'/'.$name;
# Movemos el archivo a la carpeta
move_uploaded_file($tmp, $ahora);
# Nos movemos al index.php
header("Location: index.php");
}
else
header("Location: index.php?errno=1&errmsg=Su archivo excede los ".$bytes_max."bytes.");
}
else
header("Location: index.php?errno=1&errmsg=No ah seleccionado ningun archivo.");
?>
=====================================================
pero no hace nada.....
gracias por su ayuda.
siREZ
Valora esta pregunta


0