Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/08/2011, 07:32
nuevoconphp
 
Fecha de Ingreso: febrero-2011
Mensajes: 64
Antigüedad: 13 años, 2 meses
Puntos: 3
Barra de progreso Jquery y PHP

Hola a todos,

tengo el siguiente codigo php para subir mi archivo al servido

Código PHP:
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  if (
PHP_VERSION 6) {
    
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}

$editFormAction $_SERVER['PHP_SELF'];



if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}



if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "boletin")) {
    
    
//This function separates the extension from the rest of the file name and returns it  

function findexts ($filename) { $filename strtolower($filename) ; 
$exts split("[/\\.]"$filename) ; 
$n count($exts)-1$exts $exts[$n]; return $exts; } 

//This applies the function to our file  

$ext findexts ($_FILES['uploaded']['name']) ;

//This line assigns a random number to a variable. You could also use a timestamp here if you prefer.  
$day =$_POST['day'];
$ran 'boletin' 

//This takes the random number (or timestamp) you generated and adds a . on the end, so it is ready of the file extension to be appended. 

$ran2 $ran.".";

//This assigns the subdirectory you want to save into... make sure it exists! 

$target "uploads/"


//This combines the directory, the random file name, and the extension 

$target $target .  $day ' ' $ran2.$ext;
  
 
if(
move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { 

echo 
"The file has been uploaded as ".$ran2.$ext; } 

else { echo 
"Sorry, there was a problem uploading your file."; }
  
$insertSQL sprintf("INSERT INTO boletin (fecha, direccion) VALUES (%s, %s)",
                       
GetSQLValueString($_POST['day'], "text"),
                       
GetSQLValueString('uploads/'.$_POST['day']. ' ' .'boletin' '.' .$ext"text"));

  
mysql_select_db($database_mi_iglesia$mi_iglesia);
  
$Result1 mysql_query($insertSQL$mi_iglesia) or die(mysql_error());

  
$insertGoTo "boletin.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$insertGoTo));
  

  
}

mysql_select_db($database);
$query_boletin "SELECT * FROM boletin";
$boletin mysql_query($query_boletin$mi) or die(mysql_error());
$row_boletin mysql_fetch_assoc($boletin);
$totalRows_boletin mysql_num_rows($boletin);
?>

aqui mi codigo html:


Código HTML:
<div class="casillas_mediano" id="casillas_mediano">  

  <div class="forma" id="forma">
  <form name="boletin" action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" id="boletin"> 
  <p>
  <input name="uploaded" type="file" /> Please choose a file
  </p>
  <p> 
       
    <input name="day" type="text" id="day" value="" size="15" readonly="readonly"/> Dia
  
    <br /> 
    <br />
    <input type="submit" value="Upload" />
  </p>
  <input type="hidden" name="MM_insert" value="boletin" />
  </form> 
  </div>
  
  
  <div id="progressbar">
  </div> 
Mi pregunta es si alguien me pudiera ayudar a implementar el plugin de la barra de progresso para que muestre el transcurso de la subida del aqchivo. No se si me dejo explicar. He visto varios articulos en Internet pero no los entiendo muy bien.

muchas gracias