Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/08/2013, 15:26
jorgemibanez
Invitado
 
Mensajes: n/a
Puntos:
Pregunta Problema al solicitar elemento al servidor

El siguiente código sube una imagen que luego es mostrada a través de un código PHP, pero la imagen no sale, aparece un icono de imagen no encontrada, sin embargo está allí. ¿Alguna idea?

<form id="form_upload_photo" enctype="multipart/form-data" name="frmMain" action="upload_image.php" method="post">

<input name="filUpload" id="filUpload" type="file" onchange="document.getElementById('form_upload_pho to').submit()">

</form>

Este código sube la imagen inmediatamente después de ser seleccionada, y luego la muestra:

<?php
$target = "images/";
$target = $target . basename( $_FILES['filUpload']['name']);
$filUpload_size = $_FILES['filUpload']['size'];
$filUpload_type = $_FILES['filUpload']['type'];
$ok=1;

//This is our size condition
if ($filUpload_size > 350000)
{
echo "Your file is too large.<br>";
$ok=0;
}

//This is our limit file type condition
if ($filUpload_type =="text/php")
{
echo "No PHP files<br>";
$ok=0;
}

//Here we check that $ok was not set to 0 by an error
if ($ok==0)
{
Echo "Sorry your file was not uploaded";
}

//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['filUpload']['tmp_name'], $target))
{
echo '

<img id="imgAvatar" src="<?php echo $target;?>"/>

Me he saltado varias etiquetas que ya sabemos van en todo código y he puesto lo principal.

Gracias por vuestra ayuda.