te juro que estoy llorando, me funcionoooo!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
esta es la solucion:
Código Javascript
:
Ver original<script type="text/javascript">
// <![CDATA[
$(document).ready(function() {
$('#file_upload').uploadify({
'uploader' : 'dify/uploadify.swf',
'script' : 'dify/uploadify.php',
'cancelImg' : 'dify/cancel.png',
'folder' : '/uploads',
'buttonText': 'Cambiar Foto',
'sizeLimit' : '5242880',
'scriptData' : {'fid':<?php echo $getUsuario;?>},
'displayData': 'percentage',
'fileExt' : '*.jpg;*.gif;*.png;*jpeg',
'fileDesc' : 'Image Files',
'onComplete' : function(event, ID, fileObj, response, data) {
window.location.reload();
},
'auto' : true
});
});
// ]]>
</script>
Bien, ahora me falta solo la parte de PHP donde tengo la clase esa, no se como obtener las dos rutas de las imagenes, como puedo hacerlo?, este es el script:
Código PHP:
Ver original<?php
/*
Uploadify v2.1.4
Release Date: November 8, 2010
Copyright (c) 2010 Ronnie Garcia, Travis Nickels
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
class Image {
var $uploaddir;
var $quality = 100;
var $ext;
var $dst_r;
var $img_r;
var $img_w;
var $img_h;
var $output;
var $data;
var $datathumb;
function setFile($src = null) {
if(is_file($src) && ($this->ext == "JPG" OR
$this->ext == "JPEG")) { } elseif(is_file($src) && $this->ext == "PNG") { } elseif(is_file($src) && $this->ext == "GIF") { }
$this->img_w = imagesx($this->img_r); $this->img_h = imagesy($this->img_r); }
function resize($w = 100) {
$h = $this->img_h / ($this->img_w / $w);
imagecopyresampled($this->dst_r, $this->img_r, 0, 0, 0, 0, $w, $h, $this->img_w, $this->img_h); $this->img_r = $this->dst_r;
$this->img_h = $h;
$this->img_w = $w;
}
function createFile($output_filename = null) {
if($this->ext == "JPG" OR $this->ext == "JPEG") {
imageJPEG($this->dst_r, $this->uploaddir.$output_filename.'.'.$this->ext, $this->quality); } elseif($this->ext == "PNG") {
imagePNG($this->dst_r, $this->uploaddir.$output_filename.'.'.$this->ext); } elseif($this->ext == "GIF") {
imageGIF($this->dst_r, $this->uploaddir.$output_filename.'.'.$this->ext); }
$this->output = $this->uploaddir.$output_filename.'.'.$this->ext;
}
function setUploadDir($dirname) {
$this->uploaddir = $dirname;
}
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_GET['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
//imagedestroy($this->img_r);
}
}
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $prefijo .'_' . $_FILES['Filedata']['name'];
$image = new Image();
$image->setFile($targetFile);
$image->setUploadDir($targetPath);
$image->resize(640);
$image->createFile(md5($tempFile)); $image->resize(250);
$image->createFile("s_".md5($tempFile)); }
$userrr = $_REQUEST['fid'];
include('conexion.php');
mysql_query('INSERT fotos SET pertenecea_foto = "'.$userrr.'"',$db); ?>
La ultima consulta es una prueba para ver si recibia la variable de ajax, bien, lo que deseo ahora es obtener las dos rutas de las dos imagenes, lo malo es que obtengo la ruta de la original y no la de las redimensionadas..
$targetFile es la ruta original, no se de que manera obtener las de las redimensionadas, en total se almacenan 3 imagenes(la original, thumb y otra que esta redimensionada a 640)