Dateien vom FTP per PHP kopieren

grimoh

Mitglied
Hallo,

Ich denke mal, das ist nur wieder ein kleiner Denkfehler, aber nach 3 Tagen experimentieren, mache ich mehr kaputt als fertig ;)

Ich habe folgende Ordner-Struktur:

/srv/www/htdocs/web266/html/
/srv/www/htdocs/web266/html/neu/ <--- hier liegt die gesamte homepage
/srv/www/htdocs/web266/html/neu/gallery/import <--- hier ftp uploaded Bilder
/srv/www/htdocs/web266/html/neu/gallery/$categorie/ <--- per php kategorie erstellte bilder
/srv/www/htdocs/web266/html/neu/gallery/thumb/$category <--- per php erzeugte thumbs

Das ganze läuft auf BXCP

In einer import.php frage ich nur ab, in welche Kategorie die Bilder importiert werden sollen!

PHP:
<?php if($access<3) { echo $noacc; } else { ?>
<table cellpadding="0" cellspacing="2" border="0" style="width: 98%;">
<tbody><tr>
  <td class="left"><strong>Import&gt;&gt;</strong></td>
</tr></tbody></table><br>
<table cellpadding="0" cellspacing="2" border="0" style="width: 98%;"><tbody><tr><td class="main">
<form enctype="multipart/form-data" action="index.php?show=importaction" method="post">
<table style="width: 98%;"><tbody><tr>
  <td>Kategorie</td><td class="left">
<select name="category" id="category" class="form">
<option value="">----</option>
<?php 
$sql="SELECT * FROM category WHERE `table`= 'gallery' ORDER BY name";
$data=mysql_query($sql, $db);
while ($cat = mysql_fetch_object ($data)) {
print "<option value=\"$cat->short\">$cat->name</option>"; } ?>
</select>
</td></tr><tr><td>Optionen</td><td class="left"> 
<input type="hidden" class="form" name="compress" value="1" />
<input value="Absenden" class="form" type="submit" enctype="multipart/form-data">
<input value="Nochmal" class="form" type="reset">
</td></tr></tbody></table>
</form></td></tr></tbody></table>
<?php } ?>

In der importaction.php SOLL folgendes gemacht werden!

Gesamtes Verzeichnis auslesen, Jede Datei, jeweils in

gallery/$category/ UND gallery/thumb/$category/

kopiert werden!

Danach sollen die Dateien verkleinert werden!

Dann sollen die Dateien in eine Datenbank eingetragen werden!

Das versuche ich folgendermassen!

importaction.php

PHP:
<?
$category=$_POST['category'];
$name='Bild';
$info='Import';
$zahl=1;

include ("system/func_resize.php");

function kopieren ($ordner) {
  $dir = opendir($ordner);
  while ($file = readdir($dir)) {
    if ($file != '..' && $file != '.' && $file != '') {

    copy($file, "thumb/$category/$file");

	copy($file, "$category/$file");

	resize("$category/$file", $filex,  "1000", "400");

	resize("thumb/$category/$file", $filex,  "75", "75");

	$add="INSERT INTO gallery (name, info, thumb, img, category, fav) VALUES ('$name'.'$zahl', '$info', '$file', '$file', '$category', '$fav')"; 

	$sqlaction=mysql_query($add);
	
	$zahl=$zahl++;
      }
  }
  closedir($ordner);
  }
kopieren ('gallery/import');
?>

Und jetzt suche ich meinen Denkfehler.........

Warning: copy(Bild000.jpg): failed to open stream: No such file or directory in /srv/www/htdocs/web266/html/neu/show/importaction.php on line 14

Warning: copy(Bild000.jpg): failed to open stream: No such file or directory in /srv/www/htdocs/web266/html/neu/show/importaction.php on line 16

Warning: copy(): open_basedir restriction in effect. File(/Bild000.jpg) is not within the allowed path(s): (/srv/www/htdocs/web266/html/:/srv/www/htdocs/web266/phptmp/:/srv/www/htdocs/web266/files/:/srv/www/htdocs/web266/atd/) in /srv/www/htdocs/web266/html/neu/system/func_resize.php on line 44

Warning: copy(/Bild000.jpg): failed to open stream: Operation not permitted in /srv/www/htdocs/web266/html/neu/system/func_resize.php on line 44

Warning: copy(thumb//Bild000.jpg): failed to open stream: No such file or directory in /srv/www/htdocs/web266/html/neu/system/func_resize.php on line 44

Warning: copy(Bild001.jpg): failed to open stream: No such file or directory in /srv/www/htdocs/web266/html/neu/show/importaction.php on line 14

Warning: copy(Bild001.jpg): failed to open stream: No such file or directory in /srv/www/htdocs/web266/html/neu/show/importaction.php on line 16

Warning: copy(): open_basedir restriction in effect. File(/Bild001.jpg) is not within the allowed path(s): (/srv/www/htdocs/web266/html/:/srv/www/htdocs/web266/phptmp/:/srv/www/htdocs/web266/files/:/srv/www/htdocs/web266/atd/) in /srv/www/htdocs/web266/html/neu/system/func_resize.php on line 44

Warning: copy(/Bild001.jpg): failed to open stream: Operation not permitted in /srv/www/htdocs/web266/html/neu/system/func_resize.php on line 44

Warning: copy(thumb//Bild001.jpg): failed to open stream: No such file or directory in /srv/www/htdocs/web266/html/neu/system/func_resize.php on line 44

.............

Ich komme einfach nicht mehr weiter!
Über ein wenig Hilfe wäre ich sehr dankbar

GriMoh

EDIT:

Also, die importaction.php habe ich folgendermassen geändert:

PHP:
<?


include ("system/func_resize.php");

function kopieren ($ordner) {
  $dir = opendir($ordner);
  $zahl=0;
  while ($file = readdir($dir)) {
    if ($file != '..' && $file != '.' && $file != '') {
	
	$category=$_POST['category'];
    $name='Bild';
	$info='Import';

        copy($file, "gallery/thumb/$category/$file");

	copy($file, "gallery/$category/$file");

	resize("gallery/$category/$file", $filex,  "1000", "400");

	resize("gallery/thumb/$category/$file", $filex,  "75", "75");

	$add="INSERT INTO gallery (name, info, thumb, img, category, fav) VALUES ('$name $zahl', '$info', '$file', '$file', '$category', '$fav')"; 

	$sqlaction=mysql_query($add);
	
	$zahl=$zahl++;
      }
  }
  closedir($ordner);
  }
kopieren ('gallery/import');
?>

So, das mit der Zahl funktioniert noch nicht, was das geringere übel ist! Das als name Bild1....Bild100 eingetragen wird, ABER..

der Ordner $category ist von PHP erstellt worden! Jetzt muss das PHP script die datei, die per ftp hochgeladen wurde, in den ordner $category UND thumb/$category kopieren!

nur WIEEEEE
argh *am galgen hänge*
 
Zuletzt bearbeitet:

Neue Beiträge

Zurück