Upload mit entpacken

ja super ;)
jetzt habe ich den pfad direkt eingetragen :
Code:
exec(unzip /opt/lampp/htdocs/35mm/imagefolder1/bilder.zip);
aber dann kommt trotzdem nen fehler :(
Parse error: parse error, unexpected T_STRING in /opt/lampp/htdocs/35mm/upload1.php on line 20
 
ja thx jetzt kommt zwar kein fehler aber entpachen tut er sie auch nicht.
a mom wenn ichs so mache
Code:
exec("unzip /opt/lampp/htdocs/35mm/imagefolder1/bilder.zip");
entpackt er sie da wo das upload1.php script aufgerufen wird und nicht in das obige verzeichniss.
 
Zuletzt bearbeitet:
juppi danke jetzt gehts
habe es erstmal so gelöst.
Ich werde noch den kommpletten code uppen fals noch jemand das prob. hat:
THXTHX ersmal.
 
so bitte:
Code:
<?
require('config.php'); // ist der apsolute pfad drin $abpath = /opt/lampp/htdocs/...
if ($button=="upp")
{
  if($_FILES["datei"]["name"] == "")
   {
     echo "keine Datei";
   }
  else
   {
     if($_FILES["datei"]["tmp_name"] == "")
      {
        echo "Fehler bei der Übertragung. (Eventuell Datei zu groß.. max. 2 MB)";
      }
     else
      {
//Datei hochladen entpacken und zip datei wider löschen
        if (move_uploaded_file($_FILES["datei"]["tmp_name"],$abpath."/".$select."/".$_FILES["datei"]["name"]))   
         {
          $file = $abpath."/".$select."/".$_FILES["datei"]["name"];
	  $ordner = $abpath."/".$select."/";
          exec("unzip -d $ordner $file");
	  exec("rm $file");
          echo "fertig";
         }
     else
         {
          echo "doch ein fehler";
         }    
      }
   }
}
else
{
  ?>
  <table width="100%" border="0" cellpadding="1" cellspacing="1" style="border-collapse: collapse">
  <tr>
  <td colspan="2" height="25"><center>Datei Upload</center></td>
  </tr>
  <tr>
  <td width="100%" align="left"><br>
  <center>
  <form action="upload1.php" method="post" enctype="multipart/form-data">
  <table>
      <tr>
      <?
//scanne verzeichnisse / auswahl des Verzeichnisses 
      $dh = opendir($dir);
  while($file = readdir($dh))
   {
    if ($file != "." && $file != ".." && is_dir($file))   
     {
      $dname[] = $file;
      sort($dname);
      reset ($dname);
     }
   }
  print "<hr align='left' width='400'><br>";
  print "<b>Upload to:</b> <select name=\"select\">";
  print "<option value=\"#\">Choose. . .</option><br>\n";
  $u=0;
  foreach($dname as $key=>$val)
   {
    if($dname[$u])   
     {
      print "<option value=\"$dname[$u]\">$dname[$u]</option>\n";
      $u++;
     }
   }
  print "</select>";
  ?>
  <td>Datei auswählen: (max. 2 MB) <input name="datei" size="50" type="file">
  <input type="submit" value="upp" name="button"></td>
  </tr>
  </table>
  <?
}
?>
 
ok hier nochmal volständig (is von der Slide gallery)
upload.php
Code:
<?php

require('config.php');

function error ($error_message) {
	echo $error_message."<BR>";
	exit;
}

if ( (!isset($PHP_AUTH_USER)) || ! (($PHP_AUTH_USER == $LOGIN) && ( $PHP_AUTH_PW == "$PASSWORD" )) ) {
	header("WWW-Authenticate: Basic entrer=\"Form2txt admin\"");
	header("HTTP/1.0 401 Unauthorized");
	error("Unauthorized access...");
}


if ($_REQUEST['submitted2'])
{
umask (0);

mkdir ("$abpath/$newdir", 0755);
chmod ("$abpath/$newdir",0777);
$file = fopen("$abpath/$newdir/album.txt","w");
chmod ("$abpath/$newdir/album.txt",0777);
fwrite($file,"$album");
fclose($file);
}

if ($_REQUEST['submitted']){ // Begin processing portion of script


$log = "";

for ($i=0; $i<$number_of_uploads; $i++) {
$j=$i + 1;


if($select =="Choose. . ."){
$log .= "Please Choose Upload Directory<br>";
} else {

	//checks if file exists
	if ($img_name[$i] == "") {
		$log .= "No file selected for upload $j<br>";
	}

	if ($img_name[$i] != "") {
		//checks if file exists
		if (file_exists("$abpath/$select/$img_name[$i]")) {
			$log .= "File $j already existed<br>";
		} else {

			//checks if files to big
			if (($sizelim == "yes") && ($img_size[$i] > $size)) {
				$log .= "File $j was too big<br>";
			} else {


				//Checks if file is an image
				if( (substr($img_name[$i],-3)=="gif") || (substr($img_name[$i],-3)=="jpg")  || (substr($img_name[$i],-3)=="JPG") || (substr($img_name[$i],-3)=="txt") || (substr($img_name[$i],-3)=="TXT") || (substr($img_name[$i],-3)=="GIF") || (substr($img_name[$i],-3)=="zip") ) {
				
					@copy($img[$i], "$abpath/$select/$img_name[$i]") or $log .= "Couldn't copy image 1 to server<br>";
					//Angepaster code für ZIP ARCHIVE
if(substr($img_name[$i],-3)=="zip")
{
 $file = $abpath."/".$select."/".$img_name[$i];
	  $ordner = $abpath."/".$select."/";
	  exec("unzip -d $ordner $file");
exec("rm $file");
$log .= "Zip hochgeladen und entpackt! Juppi<br>"; 
}
$file = fopen("$abpath/$select/$img_name[$i].txt","w");
chmod ("$abpath/$select/$img_name[$i].txt",0777);
fwrite($file,"$comnt[$i]");
fclose($file);


					if (file_exists("$abpath/$select/$img_name[$i]")) {
						$log .= "File $j was uploaded<br>";
						
					}
					} else {
						$log .= "File $j is not an image or text file<br>";
					}
				}
			}
		}

}
	
}

?>

<html>
<head>
<title>Image Report</title>
</head>
<body>
<p>Log:<br>
<?

echo "$log";

?>
</p>
<a href="upload.php">back</a>
<body>
</html>
<? 
exit;
} // End processing portion of script
?>

<html>
<head>
       <title>35mm Slide Gallery - Upload Module Aber nich Original mit zip funktion</title>
<link rel="stylesheet" type="text/css" href="gallery.css">
</head>
<body>
<div align="right"><font size="1">powered by <a href="http://www.andymack.com/freescripts/">35mm 
  Slide Gallery</a></font></div>
<form method=POST action=upload.php enctype=multipart/form-data>
<input type="hidden" name="submitted2" value="true">
<b>Create New Album: </b><input type="text" name="newdir">
<br><b>Album Description: </b> <input type="text" name=album size=20>
<input type="submit" name="submit" value="Create"> 
</form>
<form method=POST action=upload.php enctype=multipart/form-data>
<?php
$dh = opendir($dir);
 while($file = readdir($dh))
 {
if ($file != "." && $file != ".." && is_dir($file))   
{$dname[] = $file;
sort($dname);
reset ($dname);
 }
}
print "<hr align='left' width='400'><br>";
print "<b>Upload to:</b> <select name=\"select\">";
print "<option value=\"#\">Choose. . .</option><br>\n";
$u=0;
 foreach($dname as $key=>$val)
  {  if($dname[$u])   
{ print "<option value=\"$dname[$u]\">$dname[$u]</option>\n";
$u++;
}
}
print "</select>";

?>
<p><b>Files to upload: (Einfach 1 Zip Archiv oder mehrere Bilder hier auswählen)</b><br>
<blockquote>
<?php

for ($j=0; $j<$number_of_uploads; $j++) {
?>
<input type=file name=img[] size=30> <br><b>Caption</b> <input type="text" name=comnt[] size=30><p>
<?
}
?>
<br> 
<input type="hidden" name="submitted" value="true">
<input type="submit" name="submit" value="Upload"> 
</form>
</blockquote>
go to <a href="index.php">gallery</a>
</body>
</html>

config.php

Code:
<?php

//Slide gallery variables
$place = "."; //directory of the slide mount images, no need to change
$col = 5; //no. of columns in a page
$maxrow = 10; //no. of rows in a page
$dir="."; //directory for this script, no need to change
$thumb = true ; //setting it to TRUE will generate real thumbnails on-the-fly, supports jpg file only and requires GD library. Setting it to FALSE will resize the original file to fit the thumbnail size, long download time. Turn it off if thumbnails don't show properly.
$croptofit = true ; //TRUE will crop the thumbnail to fit the aspect ratio of the slide mount if they aren't the same. False won't crop the thumbnail but it will be distorted if both aspect ratios are not the same.
$rollover = true ;  //thumbnail rollover effect for IE only

//Upload/Delete Module variables
$LOGIN = "admin";
$PASSWORD = "admin";
$abpath = "/opt/lampp/htdocs/test2"; //Absolute path to where images are uploaded. No trailing slash
$sizelim = "no"; //Size limit, yes or no
$size = "2500000"; //Size limit if there is one
$number_of_uploads = 5;  //Maximum number of uploads in one time

?>
 
Hallo und guten Morgen,

Sorry dass ich hier nochmals was schreiben aber ich denke das ist besser, wie wenn ich wieder einen neuen Thread auf mache.

Hab mir das ganze mal angesehen und auch nachgemacht. Ein Teil geht auch schon aber leider noch nicht alles.

Ich schreibe hier einfach mal die Felher was da kommen:

Code:
Warning: exec,system,passthru,shell_exec,popen,escapeshellcmd,proc_open,proc_nice() has been disabled for security reasons in /www/htdocs/v148718/impressum/upload.php on line 68

Warning: exec,system,passthru,shell_exec,popen,escapeshellcmd,proc_open,proc_nice() has been disabled for security reasons in /www/htdocs/v148718/impressum/upload.php on line 69

Warning: fopen(/www/htdocs/v148718/impressum/test/test/7318.02c27682b80b462437ba4efc71267562.thumb.zip.txt) [function.fopen]: failed to create stream: No such file or directory in /www/htdocs/v148718/impressum/upload.php on line 72

Warning: chmod() [function.chmod]: No such file or directory in /www/htdocs/v148718/impressum/upload.php on line 73

Warning: fwrite(): supplied argument is not a valid stream resource in /www/htdocs/v148718/impressum/upload.php on line 74

Warning: fclose(): supplied argument is not a valid stream resource in /www/htdocs/v148718/impressum/upload.php on line 75

Log:
Couldn't copy image 1 to server
Zip hochgeladen und entpackt! Juppi
No file selected for upload 2
No file selected for upload 3
No file selected for upload 4
No file selected for upload 5

In der Zeile 68 steht:

PHP:
exec("unzip -d $ordner $file");

In der Zeile 69 steht:

PHP:
exec("rm $file");

In der Zeile 72 - 75 steht:

PHP:
$file = fopen("$abpath/$select/$img_name[$i].txt","w");
chmod ("$abpath/$select/$img_name[$i].txt",0777);
fwrite($file,"$comnt[$i]");
fclose($file);

Ich kann leider mit dem nicht wirklich was anfangen. Kann mir da jemand weiter helfen?
 
Zurück