Jump to content
Fórum Script Brasil
  • 0

Erro ao fazer upload de imagem


Ana Gabriela Raitz

Question

Boa tarde pessoal estou com um erro ao fazer um upload de imagem para o servidor. O erro é:

Checking propertyphoto3$_FILES [ propertyphoto3 ] [ "error" ] = 0 (UPLOAD_ERR_OK = 0)

Segue abaixo o fonte:

<?php

require ( "../includes/config.php" );
require ( "../includes/CGI.php" );
require ( "../includes/SQL.php" );

$cgi = new CGI ();
$sql = new SQL ( $DBusername, $DBpassword, $server, $database );

if ( ! $sql->isConnected () )
{
  die ( $DatabaseError );
}



?>
<html>
<head>
<title>Adicionar Imagem</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<?

require ( "resizer.php" );
require ( "../includes/CSQL.php" );

if ( $cgi->getValue ( "Submit" ) == 'Atualizar Imagem' )
{
  $img = $cgi->getValue ( "img" );
  $propertyphotos [ $img ] = "";
  $t = "propertyphoto" . $img;
  error_log ( "Checking propertyphoto" . $img );
  
  if ( ! isset ( $_FILES [ $t ] ) || 
       ! is_uploaded_file ( $_FILES [ $t ] [ 'tmp_name' ] ) )
  {
    error_log ( "Breaking, no uploaded file?" );
    
    print "<br><p align=\"center\"><strong>No Image Uploaded</strong></p>";
  }

  error_log ( "\$_FILES [ " . $t . " ] [ \"error\" ] = " . $_FILES [ $t ] [ "error" ] . " (UPLOAD_ERR_OK = " . UPLOAD_ERR_OK . ")" );
  
      if ( $_FILES [ $t ] [ "error" ] == UPLOAD_ERR_OK )
      {
              $tmp_name = $_FILES [ $t ] [ "tmp_name" ];
            
      $name = $_FILES [ $t ] [ "name" ];
     $propertyphotos = $_POST [ 'ref' ] . "-" . $img . "-" . $name;



      ResizeConserveAspectRatio($tmp_name, $ImagePath . "/" . $propertyphotos, $max_image_resize_width); 

      }

  $sql_update = "UPDATE " . $property_table . " SET propertyphoto" .
      $img . "=" . $sql->quote ( $propertyphotos ) .
      " WHERE id=" . $sql->quote ( $cgi->getValue ( "id" ) );

  $rows = $sql->execute ( $sql_update );

?>
<p>&nbsp;</p>
<p align="center"> Atualizado  <br />
<a href="#" onClick="opener.location.reload( true );window.close();">Fechar e voltar</a></p>
<br />
<?
}
else
{
?>
<h2 align="left"><img src="images/spacer.gif" height="10" width="15" /> 
Adicionar Imagem <?php echo $cgi->htmlEncode ( $cgi->getValue ( "img" ) ); ?></h2>
<p>Use o campo abaico para escolhaer uma nova imagem.</p>
<form method="post" enctype="multipart/form-data" id="add image">
<input type="hidden" name="img" value="<?php echo $cgi->htmlEncode ( $cgi->getValue ( 'img' ) ); ?>" />
<input type="hidden" name="id" value="<?php echo $cgi->htmlEncode ( $cgi->getValue ( 'id' ) ); ?>" />
<input type="hidden" name="ref" value="<?php echo $cgi->htmlEncode ( $cgi->getValue ( 'ref' ) ); ?>" />
<input type="file" name="propertyphoto<?php echo $cgi->htmlEncode ( $cgi->getValue ( 'img' ) ); ?>" />
<br />
<br>
<input type="submit" name="Submit" value="Atualizar Imagem" />
</form>
<?
}
?>
</body>
</html>

Alguém tem ideia do que pode estar ocorrendo?

Edited by kuroi
Adicionar tag CODE
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...