Sie sind auf Seite 1von 7

Select a page

Cmo subir un archivo con jQuery y Ajax + PHP


(http://blog.eltallerweb.com/como-subir-un-archivo-conjquery-y-ajax-php/)
Programacin (http://blog.eltallerweb.com/category/programacion/)
JQUERY (http://blog.eltallerweb.com/category/programacion/jquery/)

by Joge23 (http://blog.eltallerweb.com/author/joge23_/)
- feb 1, 2013
0 (http://blog.eltallerweb.com/como-subir-un-archivo-con-jquery-y-ajax-php/#comments)

19498

(http://blog.eltallerweb.com/wp-content/uploads/2012/09/iconos-07.png)
Por Juan Carlos Sosa
Para subir un archivo con jQuery y Ajax + PHP, en lugar de utilizar un plugin ya desarrollado y probado,
podemos utilizar la lgica de cmo se enva un archivo con Ajax:
function uploadAjax(){
var inputFileImage = document.getElementById(archivoImage);
var file = inputFileImage.files[0];

var data = new FormData();


data.append(archivo,file);
var url = upload.php;
$.ajax({
url:url,
type:POST,
contentType:false,
data:data,
processData:false,
cache:false});
}
Configurando el Html de la pgina, algo similar tiene que quedar el Input:
<input type=file name=archivoImage id=archivoImage />
<input type=button id=botonSubidor onclick=uploadAjax() />
Tambin pueden hacerlo con jQuery:
$(document).ready(function() {

$(#botonSubidor).click(uploadAjax);})

Obviamente el html tiene que quedar as:


<input type=file name=archivoImage id=archivoImage />
<input type=button id=botonSubidor />
El archivo upload.php
//upload.php
$return = Array(ok=>TRUE);
$upload_folder =images';
$nombre_archivo = $_FILES[archivo][name];
$tipo_archivo = $_FILES[archivo][type];
$tamano_archivo = $_FILES[archivo][size];
$tmp_archivo = $_FILES[archivo][tmp_name];
$archivador = $upload_folder . / . $nombre_archivo;
if (!move_uploaded_file($tmp_archivo, $archivador)) {

$return = Array(ok => FALSE, msg => Ocurrio un error al subir el archivo. No pudo guardarse., status
=> error);
}
echo json_encode($return);
Espero que esta informacin les sea de utilidad Ustedes cmo lo haran?
Ajax (http://blog.eltallerweb.com/tag/ajax/)

archivo (http://blog.eltallerweb.com/tag/archivo/)

ejemplo (http://blog.eltallerweb.com/tag/ejemplo/)
PHP (http://blog.eltallerweb.com/tag/php/)

jquery (http://blog.eltallerweb.com/tag/jquery-2/)

Programacion (http://blog.eltallerweb.com/tag/programacion-2/)

subir (http://blog.eltallerweb.com/tag/subir/)

PREVIOUS ARTICLE

Caso de xito, Cisco Webex (http://blog.eltallerweb.com/caso-de-exito-cisco-webex/)


NEXT ARTICLE

Comparando MySQL y Mongo DB (http://blog.eltallerweb.com/comparando-mysql-y-mongodb/)

SIMILAR ARTICLES

(http://blog.eltallerweb.com/usuarios-y-sessiones-en-yii/)

PHP (http://blog.eltallerweb.com/category/programacion/php/)
0 (http://blog.eltallerweb.com/usuarios-y-sessiones-en-yii/#comments)

3674

Usuarios y Sessiones en Yii (http://blog.eltallerweb.com/usuarios-y-sessiones-enyii/)


by Joge23 (http://blog.eltallerweb.com/author/joge23_/) - may 19, 2015

(http://blog.eltallerweb.com/first-steps-yii-framework/)

PHP (http://blog.eltallerweb.com/category/programacion/php/)
0 (http://blog.eltallerweb.com/first-steps-yii-framework/#comments)

2911

First Steps Yii-Framework (http://blog.eltallerweb.com/ rst-steps-yii-framework/)


by Joge23 (http://blog.eltallerweb.com/author/joge23_/) - jul 31, 2013

(http://blog.eltallerweb.com/reglas-de-monitoreo-de-zend-server-6/)

Programacin (http://blog.eltallerweb.com/category/programacion/)
0 (http://blog.eltallerweb.com/reglas-de-monitoreo-de-zend-server-6/#comments)

517

Reglas de monitoreo de Zend Server 6 (http://blog.eltallerweb.com/reglas-demonitoreo-de-zend-server-6/)


by jmosqueda (http://blog.eltallerweb.com/author/jmosqueda/) - abr 17, 2013

(http://blog.eltallerweb.com/que-es-pecl/)

PHP (http://blog.eltallerweb.com/category/programacion/php/)

0 (http://blog.eltallerweb.com/que-es-pecl/#comments)

Qu es PECL? (http://blog.eltallerweb.com/que-es-pecl/)
by igormx (http://blog.eltallerweb.com/author/igormx/) - abr 16, 2013

LEAVE A REPLY
Name:
Email:
Website:

tres = 2

1190

Comment:

Post Comment
Buscar

Search

Bienvenido Lector
Estimado lector:
Te damos la bienvenida al boletn informativo de El Taller Web, en l podrs encontrar artculos
relacionados con diseo web, programacin en .NET, HMTL, PHP, jQuery y mucho ms.
El Taller Web es un centro de entrenamiento, que tiene por objetivo sentar las bases necesarias para
incrementar los conocimientos relativos a PHP y herramientas relacionadas atravs de servicios de
entrenamiento y certificacin en PHP y Zend Framework.
Esperamos que esta informacin te sea til, nos gustara que compartieras tus preguntas, comentarios y
sugerencias.
Sguemos en nuestro Twitter @ElTallerWeb o en Facebook.com/ElTallerWeb

Entradas recientes
PMP, SCRUM, MAGTIC, CMMI? Y todo esto con qu se come? (http://blog.eltallerweb.com/pmpscrum-magtic-cmmi-y-todo-esto-con-que-se-come/)
Reporte de errores a Correo (http://blog.eltallerweb.com/reporte-de-errores-a-correo/)
Que siempre Visual Studio Code para Linux y OSX (http://blog.eltallerweb.com/que-siempre-visualstudio-code-para-linux-y-osx/)
Introduccin a Sharepoint (http://blog.eltallerweb.com/introduccion-a-sharepoint/)

Usuarios y Sessiones en Yii (http://blog.eltallerweb.com/usuarios-y-sessiones-en-yii/)

Comentarios recientes
ESCRIBIR UN TEXTO SEO: CREA Un TTULO QUE TE DIFERENCIE DE LAS OTRAS | Scot Lizort
(https://scotlizort.wordpress.com/2015/06/11/escribir-un-texto-seo-crea-un-titulo-que-te-diferencie-de-lasotras/) en La importancia de usar etiquetas h1, h2, h3 (http://blog.eltallerweb.com/la-importancia-deusar-etiquetas-h1-h2-h3/#comment-52209)
Ricardo en Bootstrap vs Foundation (http://blog.eltallerweb.com/bootstrap-vs-foundation/#comment-2668)
miguel en Instala tu MediaWiki (http://blog.eltallerweb.com/instala-tu-mediawiki/#comment-2528)

Archivos
mayo 2015 (http://blog.eltallerweb.com/2015/05/)
julio 2013 (http://blog.eltallerweb.com/2013/07/)
junio 2013 (http://blog.eltallerweb.com/2013/06/)
mayo 2013 (http://blog.eltallerweb.com/2013/05/)
abril 2013 (http://blog.eltallerweb.com/2013/04/)
marzo 2013 (http://blog.eltallerweb.com/2013/03/)
febrero 2013 (http://blog.eltallerweb.com/2013/02/)
enero 2013 (http://blog.eltallerweb.com/2013/01/)
diciembre 2012 (http://blog.eltallerweb.com/2012/12/)
noviembre 2012 (http://blog.eltallerweb.com/2012/11/)
octubre 2012 (http://blog.eltallerweb.com/2012/10/)
septiembre 2012 (http://blog.eltallerweb.com/2012/09/)
agosto 2012 (http://blog.eltallerweb.com/2012/08/)
Categoras

Categoras

DISEO WEB (HTTP://BLOG.ELTALLERWEB.COM/CATEGORY/DWEB/)


GESTIN DE PROYECTOS
(HTTP://BLOG.ELTALLERWEB.COM/CATEGORY/PROGRAMACION/GESTION-DE-PROYECTOS/)
HTML5 (HTTP://BLOG.ELTALLERWEB.COM/CATEGORY/PROGRAMACION/HTML5/)
JAVASCRIPT (HTTP://BLOG.ELTALLERWEB.COM/CATEGORY/JAVASCRIPT-2/)
JQUERY (HTTP://BLOG.ELTALLERWEB.COM/CATEGORY/PROGRAMACION/JQUERY/)
PHP (HTTP://BLOG.ELTALLERWEB.COM/CATEGORY/PROGRAMACION/PHP/)
PROGRAMACIN (HTTP://BLOG.ELTALLERWEB.COM/CATEGORY/PROGRAMACION/)
REDES SOCIALES (HTTP://BLOG.ELTALLERWEB.COM/CATEGORY/REDES-SOCIALES/)
SHAREPOINT (HTTP://BLOG.ELTALLERWEB.COM/CATEGORY/SHAREPOINT/)
TECNOLOGA (HTTP://BLOG.ELTALLERWEB.COM/CATEGORY/TECNOLOGIA/)
YII (HTTP://BLOG.ELTALLERWEB.COM/CATEGORY/PROGRAMACION/YII/)
ZEND FRAMEWORK 2 (HTTP://BLOG.ELTALLERWEB.COM/CATEGORY/PROGRAMACION/ZF2/)

Das könnte Ihnen auch gefallen