Ir para conteúdo

POWERED BY:

Arquivado

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

marcos danylo

erro move_uploaded_file

Recommended Posts

Warning : move _ uploaded_ file( http:/ /

meusite.com/ /gallery /170490998 .jpg )

[function .move -uploaded -file ]: failed to open

stream : HTTP wrapper does not support writeable

connections in / home/meusite/ public_ html / upload_photo _album 2 .php on

line 154

Warning : move _ uploaded_ file() [ function.move -

uploaded-file ]: Unable to move '/ tmp/php 8ckaA 7'

to ' http:/ /meusite.com/

gallery/ 170490998 .jpg ' in /home/ meusite/

public_ html /

upload_photo _album 2 .php on line 154

Compartilhar este post


Link para o post
Compartilhar em outros sites

ola Carlos..eh assim tenho um site de rede de relacionamento..mas na parte de enviar ou fazer upload esta dando erro..E O ERRO EH ESSE QUE POSTEI ACIMA..QUERO SABER SE ALGUEM AIW SABE COMO RESOLVER..

 

O SCRIPT EH ESSE

-------------

 

 

<?php
ob_start("ob_gzhandler");

session_start();
if ($_SESSION["logged_in"]!="yes")
{
       print ("<script language='JavaScript'> window.location='login.php'; </script>");
}
 else
{

function func_makethumb_avatar_upload($filename,$width,$ext)
{
//describe dynamic image resize function for uploading user avatars and delete original
ob_start(); //output buffering
$thumb_quality = 60; // JPEG image quality (0-100) for thumbnails
$thumb_width = $width; // resized images will have this width
$req_dir = getcwd();// get current working directory

$avatar_url = $filename;//path to image

if (file_exists($avatar_url)){
list($width, $height, $type, $attr) = getimagesize($avatar_url); //...get its size and stuff like that and...
if ($width != $thumb_width && $width > $thumb_width)
{
   //...if the thumbnail is not the same size as $thumb_width we need to resize it so...

   if($ext=="jpg"||$ext=="jpeg")
   {
       $image_handle = imagecreatefromjpeg($avatar_url); //
   }
   if($ext=="png")
   {
       $image_handle = imagecreatefrompng($avatar_url); //
   }

   if($ext=="gif")
   {
       $image_handle = imagecreatefromgif($avatar_url); //
   }

   if($ext=="bmp")
   {
       $image_handle = imagecreatefrombmp($avatar_url); //
   }

   if($ext=="tif")
   {
       $image_handle = imagecreatefromtif($avatar_url); //
   }



   $thumb_height = round(($thumb_width / $width) * $height); //resizing etc
   $thumbnail = imagecreatetruecolor($thumb_width, $thumb_height) or
   $thumbnail = imagecreate($thumb_width, $thumb_height);
   imagecopyresampled($thumbnail, $image_handle, 0, 0, 0, 0, $thumb_width, $thumb_height, $width, $height);
   unlink($avatar_url);//now delete the original
   imagejpeg($thumbnail, $avatar_url, $thumb_quality); //actually create a jpg from $thumbnail, store it in location $avatar_url, with quality $thumb_quality

   imagedestroy($image_handle); //clear buffer #*$!
   imagedestroy($thumbnail);
   ob_end_flush();
   //end output buffering
   }
}
}


include("includes/top.php");
include("includes/nav.php");
include("includes/conn.php");
include("classes/class.gallery.php");
$gallery = new gallery;
?>

<tr>
<td valign="top">
<!-- middle_content -->

<p align='center'>

<table width='100%'>
<tr>
<td width='20%'>
<?php
   include("includes/right_gallery.php");
?>
</td>

<td width='80%' valign='top'>
<table width='100%' align='center' class='dark_b_border2' cellspacing='0' cellpadding='4'>
<tr>
<td colspan='2' class='dark_blue_white2'>
Upload Photographs
</td>
</tr>

<?php
    $album_id=addslashes($HTTP_GET_VARS["album_id"]);
    if($album_id==Null||!is_numeric($album_id))
    {
?>
<tr>
<td colspan='2' class='err_class'>
Err # Invalid album selected, cannot upload a photo.
</td>
</tr>
<?php
    }
    else
    {
        $creator = $gallery->get_album_creator($album_id);
        if($creator != $_SESSION["member_id"])
        {
?>
<tr>
<td colspan='2' class='err_class'>
Err # You are not the creator of this album, cannot upload a photo.
</td>
</tr>

<?php
         }
         else
         {
?>

<tr>
<td width='100%' colspan='2' class='txt_label'>

<?php
$image_name=$_FILES["image"]["name"];

if($image_name!=Null)
{

$picture_id = $gallery->get_max_photo_id();
$file_name1=$_FILES["image"]["name"];
$ext = strtolower(end(explode('.', $file_name1)));

if($ext!="jpg"&&$ext!="jpeg"&&$ext!="png"&&$ext!="tif"&&$ext!="gif")
{
           print "<b>Err# The image format you uploaded is not supported by our system.</b>";
}
else
{

$picture_name=$_SESSION["member_id"].$picture_id."90998".".".$ext;
$thumb_picture_name="thumb_".$_SESSION["member_id"].$picture_id."90998".".".$ext;
$picture_url="gallery/".$picture_name;
$thumb_picture_url="gallery/".$thumb_picture_name;

$result = move_uploaded_file($_FILES["image"]["tmp_name"], $gallerydir.$picture_name);

if($result)
{
 $res=copy($gallerydir.$picture_name,$gallerydir.$thumb_picture_name);

 $file_name=$gallerydir.$picture_name;
 func_makethumb_avatar_upload($file_name,400,$ext);
 $res=chmod($file_name,0755);

 $file_name=$gallerydir.$thumb_picture_name;
 func_makethumb_avatar_upload($file_name,100,$ext);
 $res=chmod($file_name,0755);
 $photo_desc=addslashes($HTTP_POST_VARS["caption"]);

 $res=$gallery->add_photo($_SESSION["member_id"],$HTTP_GET_VARS["album_id"],$picture_url,$thumb_picture_url,$photo_desc);

if($res==1)
{
           print "<b>Your image has been uploaded.</b>";
           print "<br><a href='upload_photo_album1.php?album_id=$HTTP_GET_VARS[album_id]'>Add more photos</a>";
           print "<br><a href='logincomplete.php'>Return to home</a>";

}
else
{
           print "<b>There was an error!</b>";
           print "<br><a href='upload_photo_album1.php?album_id=$HTTP_GET_VARS[album_id]'>Add more photos</a>";
           print "<br><a href='logincomplete.php'>Return to home</a>";
}


}
}
}
else
{
           print "<b>There was an error!</b>";
           print "<br><a href='upload_photo_album1.php?album_id=$HTTP_GET_VARS[album_id]'>Add more photos</a>";
           print "<br><a href='logincomplete.php'>Return to home</a>";

}
?>

</td>
</tr>

<?php
}
}
?>


</table>
</td>
</tr>
</table>
<!-- middle_content -->
<!-- Middle Text -->
<?php
include("includes/bottom.php");
}
?>

 

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

print ("<script language='JavaScript'> window.location='login.php'; </script>");

 

Utilize header("Location ");

 

Ate por que , caso o user não tenha a $_SESSIOn["logged_in"], e esteja com javascript desativado, ele não sera redirecionado

Compartilhar este post


Link para o post
Compartilhar em outros sites

ja pensei nisso tambem..ja add as permissoes cmd777 nos diretorios..mas ainda taw com o mesmo erro..um amigo m disse que esta faltando o local para salvar os arquivos..mas ja tentei..e nao estou conseguindo..

Compartilhar este post


Link para o post
Compartilhar em outros sites

Seu erro Tá aki

 $picture_name=$_SESSION["member_id"].$picture_id."90998".".".$ext;
$thumb_picture_name="thumb_".$_SESSION["member_id"].$picture_id."90998".".".$ext;
$picture_url="gallery/".$picture_name;
$thumb_picture_url="gallery/".$thumb_picture_name;

$result = move_uploaded_file($_FILES["image"]["tmp_name"], $gallerydir.$picture_name);

if($result)
{
 $res=copy($gallerydir.$picture_name,$gallerydir.$thumb_picture_name);

 $file_name=$gallerydir.$picture_name;
 func_makethumb_avatar_upload($file_name,400,$ext);
 $res=chmod($file_name,0755);

 $file_name=$gallerydir.$thumb_picture_name;
 func_makethumb_avatar_upload($file_name,100,$ext);
 $res=chmod($file_name,0755);
 $photo_desc=addslashes($HTTP_POST_VARS["caption"]);

 

Repare na complicação de colocar a $filename na function.

Faça algo mais limpo.

Compartilhar este post


Link para o post
Compartilhar em outros sites

sim .no caso eh esta ..

--------

$file_ name = $gallerydir . $picture_name ;

--------

como fikaria no caso ??

no local do $file_name eu coloko o nome do diretorio onde quero q salve os arquivos ?

 

nossa to apanhando feio viu..eh necessario duas pastas ?.no caso uma para gravar o arquivo temporariamente e outra pra receber o arquivo na funcao move_uploaded_file ...OU UMA SOH PARA AS DUAS FUNCOES FUNCIONA ??

Compartilhar este post


Link para o post
Compartilhar em outros sites

A sua $gallerydir ta sem valor, percebeu ?

 

então voce ta juntado nada com nome da imagem.

crie $gallerydir = 'diretorio/imagem/bla..bla.';

 

como disse faça algo mais limpo.

Compartilhar este post


Link para o post
Compartilhar em outros sites

~Warning : move _ uploaded_ file( http:/ /

meusite.com/ /gallery /170490998 .jpg )

 

Até onde eu sei, a função move_uploaded_file serve para mover arquivos temporários que foram previamente upados pelo script, não para mover arquivos externos como um URL.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Leozitho se voce ver move_uploaded_file($_FILES["image"]["tmp_name"], $gallerydir.$picture_name); esta pegando por um input file

 

marcos danylo não existe função imagecreatefrombmp() e nem imagecreatefromtif()

 

$HTTP_GET_VARS >> $_GET[]

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.