Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá pessoal,
to tentando fazer umas coisinhas bem simples, mas não tá dando certo mesmo...
olhem ai meu código
<?phpchmod ("../fotos/", 0777);function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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']);}$foto = $_FILES['caminho_foto']['name'];$foto_tmp = $_FILES['caminho_foto']['name_tmp'];$local = "c:\wamp\www\dream\fotos";if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO fotos (legenda_foto, data_foto, caminho_foto) VALUES (%s, NOW(), '$foto')", GetSQLValueString($_POST['legenda_foto'], "text"), GetSQLValueString($_POST['caminho_foto'], "text")); move_uploaded_file($foto_tmp, "$local/$foto"); mysql_select_db($database_con_fenasoja, $con_fenasoja); $Result1 = mysql_query($insertSQL, $con_fenasoja) or die(mysql_error());}?>
simplismente a foto não vai para o caminho especificado e no banco fica o nome da foto
Uso o wampserver 1.6.4
PORQUE Não ta Gravando?
Abraços
ok! dei uma estudada neste script q você me passou e agora estou com outro problema:
olha o codigo!
<?php//configuração**************************chmod ("c:\wamp\www\dream\fotos", 0777);chmod ("..\mini", 0777);//extensões$limitar_ext = "nao";//caminho$caminho_absoluto = "..\fotos";$caminho_absoluto2 = "..\mini";//se existir$sobreescrever = "nao";//***************************************set_time_limit(0);$nome_arquivo = $_FILES['arquivo']['name'];$tamanho_arquivo = $_FILES["arquivo"]['size'];$arquivo_temporario = $_FILES['arquivo']['tmp_name'];$imagem = $arquivo_temporario;////**************************************function geraImg($img, $max_x, $max_y, $imgNome) { //pega o tamanho $imagem_orig = imagecreatefromjpeg($img); $original_x = imagesx($imagem_orig); $original_y = imagesy($imagem_orig); // se a largura for maior que altura acho a porcentagem if($original_x > $original_y) { $porcentagem = (100 * $max_x) / $original_x; } else { $porcentagem = (100 * $max_y) / $original_y; } $tamanho_x = $original_x * ($porcentagem / 100); $tamanho_y = $original_y * ($porcentagem / 100); $image_p = imagecreatetruecolor($tamanho_x, $tamanho_y); $image = imagecreatefromjpeg($img); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $tamanho_x, $tamanho_y, $width, $height); return imagejpeg($image_p, $imgNome , 80); }// Chama a imagem, passando os par?metros a ela.geraImg($arquivo_temporario, 440, 360, $arquivo_temporario);//////////////////***************************if(!empty($arquivo_temporario)){ if($sobreescrever == "nao" && file_exists("$caminho_absoluto/$nome_arquivo")) die("Este arquivo ja existe! Mande outro!"); if(move_uploaded_file($arquivo_temporario, "$caminho_absoluto/$nome_arquivo")) { echo "Arquivo Gravado com sucesso!"; } else echo "Arquivo não pode ser copiado!";}else die("Selecione um arquivo para enviar!");?>
Tudo grava certo,o rezise também, mas a foto fica toda preta.
QQ é isso?
brother.. se você quiser pode tentar usar essa classe para upload de imagens..
clique aqui
falows