Images worden niet aangemaakt en geplaatst in folder.

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Ruben kok

ruben kok

23/10/2012 11:34:39
Quote Anchor link
Zoals de titel al zegt, ik heb een script. Ik krijg geen foutmeldingen of iets, maar het maakt/upload het plaatje, dat ik in het form meegeef, niet.

HTML:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<div id="posts">
              &nbsp;&nbsp;&nbsp;&nbsp;<img src="<?php echo $filename; ?>" />  &nbsp;&nbsp;&nbsp;&nbsp;<img src="<?php echo $filename1; ?>"  />
                <form method="post" action="" enctype="multipart/form-data" name="form1">
                <table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
               <tr><Td style="height:25px">&nbsp;</Td></tr>
        <tr>
          <td width="150"><div align="right" class="titles">Picture
            : </div></td>
          <td width="350" align="left">
            <div align="left">
              <input size="25" name="file" type="file" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10pt" class="box"/>
              
              </div></td>
              
        </tr>
        <tr><Td></Td>
        <Td valign="top" height="35px" class="help">Image maximum size <b>400 </b>kb</span></Td>
        </tr>
        <tr><Td></Td><Td valign="top" height="35px"><input type="submit" id="mybut" value="       Upload        " name="Submit"/></Td></tr>
        <tr>
          <td width="200">&nbsp;</td>
          <td width="200"><table width="200" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="200" align="center"><div align="left"></div></td>
                <td width="100">&nbsp;</td>
              </tr>
          </table></td>
        </tr>
      </table>
                </form>
 
  
              
              
              </div>


PHP:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
$change
="";
$abc="";


 define ("MAX_SIZE","4000");
 function
getExtension($str) {
         $i = strrpos($str,".");
         if (!$i) { return ""; }
         $l = strlen($str) - $i;
         $ext = substr($str,$i+1,$l);
         return $ext;
 }


 $errors=0;
  
 if($_SERVER["REQUEST_METHOD"] == "POST")
 {

     $image =$_FILES["file"]["name"];
    $uploadedfile = $_FILES['file']['tmp_name'];
    
 
     if ($image)
     {

     
         $filename = stripslashes($_FILES['file']['name']);
     
          $extension = getExtension($filename);
         $extension = strtolower($extension);
        
        
 if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
         {

        
             $change='<div class="msgdiv">Unknown Image extension </div> ';
             $errors=1;
         }

         else
         {

 $size=filesize($_FILES['file']['tmp_name']);


if ($size > MAX_SIZE*10000)
{

    $change='<div class="msgdiv">You have exceeded the size limit!</div> ';
    $errors=1;
}



if($extension=="jpg" || $extension=="jpeg" )
{

$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);

}

else if($extension=="png")
{

$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefrompng($uploadedfile);

}

else
{
$src = imagecreatefromgif($uploadedfile);
}


echo $scr;

list($width,$height)=getimagesize($uploadedfile);


$newwidth=400;
$newheight=($height/$width)*$newwidth;
$tmp=imagecreatetruecolor($newwidth,$newheight);


$newwidth1=200;
$newheight1=($height/$width)*$newwidth1;
$tmp1=imagecreatetruecolor($newwidth1,$newheight1);

imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);

imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height);
function
unique_md5() {
    mt_srand(microtime(true)*100000 + memory_get_usage(true));
    return md5(uniqid(mt_rand(), true));
}


$filename = "/beheer/uploads/".md5($_FILES['file']['name'])."". $_FILES['file']['name'];

$filename1 = "/beheer/uploads/small/".md5($_FILES['file']['name'])."". $_FILES['file']['name'];



imagejpeg($tmp,$filename,100);

imagejpeg($tmp1,$filename1,100);

imagedestroy($src);
imagedestroy($tmp);
imagedestroy($tmp1);
}}

}


?>


Alle mappen die op webserver staan zijn CHMOD777, dus ik snap eigenlijk niet meer wat er fout gaat :S
Gewijzigd op 23/10/2012 11:35:04 door Ruben kok
 
PHP hulp

PHP hulp

25/11/2024 04:59:21
 
Eddy E

Eddy E

23/10/2012 11:43:43
Quote Anchor link
Verander regel 2 eens van:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
<?php
$change
="";


...
?>


Naar:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
<?php
error_reporting(E_ALL);
$change = '';


....
?>
Gewijzigd op 23/10/2012 11:44:51 door Eddy E
 
Ruben kok

ruben kok

23/10/2012 11:53:06
Quote Anchor link
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
Notice: Undefined variable: scr in /public/sites/site/beheer/image_uploader.php on line 70

Warning: imagejpeg() [function.imagejpeg]: Unable to access /beheer/uploads/e09582c0857265956ed0eb8b5a2f0f2fCONT.jpg in /public/sites/site/beheer/image_uploader.php on line 98

Warning: imagejpeg() [function.imagejpeg]: Invalid filename in /public/sites/site/beheer/image_uploader.php on line 98

Warning: imagejpeg() [function.imagejpeg]: Unable to access /beheer/uploads/small/e09582c0857265956ed0eb8b5a2f0f2fCONT.jpg in /public/sites/site/beheer/image_uploader.php on line 100

Warning: imagejpeg() [function.imagejpeg]: Invalid filename in /public/sites/site/beheer/image_uploader.php on line 100


Great, ik ga hier even naar kijken D:
thanks in advance
 
Kris Peeters

Kris Peeters

23/10/2012 13:37:50
Quote Anchor link
Zeg, het is niet het grootste probleem, maar wil je getExtension vervangen? Die houdt geen rekening met bestandsnamen met meerdere punten.
Wat gebeurt er bv met "mijnafbeelding.jpg.exe" ?

bv. zo
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
<?php
function getExtension($item) {
  $a = pathinfo($item);
  return $a['extension'];
}

?>
Gewijzigd op 23/10/2012 13:38:53 door Kris Peeters
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.