Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

editorpa

[Resolvido] Upload

Recommended Posts

Ola meu codigo

Quero fazer uploud ,trocar o nome deles e colocar o nome deles no banco de dados.

$img0=$_FILES['img0'];
$img1=$_FILES['img1'];
$img2=$_FILES['img2'];
$img3=$_FILES['img3'];
$txt_cat=$_POST['txt_cat'];
$txt_serie=$_POST['txt_serie'];

   mysql_query("INSERT INTO produtos (categoria,serie,imgthumb,img1,img2,img3) VALUES ('$txt_cat','$txt_serie','$txt_cat$txt_serie0.jpg','$txt_cat$txt_serie1.jpg','$txt_cat$txt_serie2.jpg','$txt_cat$txt_serie3.jpg')");

copy($img0,"F:\wamp\www\kitybr\img".'$txt_cat$txt_serie0.jpg');
copy($img1,"F:\wamp\www\kitybr\img".'$txt_cat$txt_serie1.jpg');
copy($img2,"F:\wamp\www\kitybr\img".'$txt_cat$txt_serie2.jpg');
copy($img3,"F:\wamp\www\kitybr\img".'$txt_cat$txt_serie3.jpg');

 

Arquivo html

<td><input type="file" name="img0" id="img0"></td>
               </tr>
               <tr>
                 <td bgcolor="#00CCFF">img1:</td>
                 <td><input type="file" name="img1" id="img1"></td>
               </tr>
               <tr>
                 <td bgcolor="#00CCFF">img2:</td>
                 <td><input type="file" name="img2" id="img2"></td>
               </tr>
               <tr>
                 <td bgcolor="#00CCFF">img3:</td>
                 <td><input type="file" name="img3" id="img3"></td>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Warning: copy(Array) [function.copy]: failed to open stream: No such file or directory in

 

<?php
$img0=$_FILES['img0']; 
$img1=$_FILES['img1']; 
$img2=$_FILES['img2']; 
$img3=$_FILES['img3']; 
copy($img0,"./".$img0_name); 
copy($img1,"./".$img1_name); 
copy($img2,"./".$img2_name); 
copy($img3,"./".$img3_name);
?>

<body>
<form id="form1" name="form1" method="post" action="<?PHP $php_self ?>">
 <input type="file" name="img0" id="img0" />
 <input type="file" name="img1" id="img1" />
 <input type="file" name="img2" id="img2" />
 <input type="file" name="img3" id="img3" />
 <input type="submit" value="ENVIAR" />
</form>
</body>

Compartilhar este post


Link para o post
Compartilhar em outros sites

<body>
<form id="form1" name="form1" method="post" enctype="multipart/form-data">
<input type="file" name="img0" id="img0" />
<input type="file" name="img1" id="img1" />
<input type="file" name="img2" id="img2" />
<input type="file" name="img3" id="img3" />
<input type="submit" name="sendFiles" value="ENVIAR" />
</form>
</body>
<?php
if($_POST['sendFiles'])
 {
  $img0 = $_FILES["img0"]["tmp_name"];
  $img1 = $_FILES["img1"]["tmp_name"];
  $img2 = $_FILES["img2"]["tmp_name"];
  $img3 = $_FILES["img3"]["tmp_name"];

  $fName0 = $_FILES["img0"]["name"];
  $fName1 = $_FILES["img1"]["name"];
  $fName2 = $_FILES["img2"]["name"];
  $fName3 = $_FILES["img3"]["name"];

  $dirUpload0 = './' . $fName0 ;
  $dirUpload1 = './' . $fName1 ;
  $dirUpload2 = './' . $fName2 ;
  $dirUpload3 = './' . $fName3 ;

   $upload0 = move_uploaded_file( $img0, $dirUpload0 );
   $upload1 = move_uploaded_file( $img1, $dirUpload1 );
   $upload2 = move_uploaded_file( $img2, $dirUpload2 );
   $upload3 = move_uploaded_file( $img3, $dirUpload3 );

 }
?>

Tente assim , (não testei) to sem php instalado aqui , informe os erros ..

Compartilhar este post


Link para o post
Compartilhar em outros sites

Andrey,muito obrigado ,funcionou perfeitamente.

 

E se alguem precisa de um host e querer desconto(20%) fale comigo.

 

editorpa.com.br

 

Topico Resolvido

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.