Zum Inhalt springen

Erweiterung File Upload

Erstellt am 6. November 2003 · 4 Antworten · letzte Antwort am 22. November 2003

Tags: Frage

manfredo ·

Hallo,

ich habe mir die Erweiterung: File Upload installiert - die Seite mit dem Plugin wird auch angezeigt und ich kann auch eine Datei zum Upload aussuchen, wenn ich dann auf "upload" klicke passiert überhaupt nichts.
Die Seite wird einfach neu angezeigt - aber keine Meldung ob der upload erfolgreich wahr oder nicht.

Die Datei ist auch nirgends zu finden, weder in dem Ordner den ich angegeben habe noch sonst wo.

Hier mein Setup:

#*** Fileupload
plugin.tx_fileupload_pi1.checkMime = 0
plugin.tx_fileupload_pi1.mimeInclude = image/gif,image/jpeg,application/x-zip-compressed
plugin.tx_fileupload_pi1.mimeExclude = application/octet-stream
plugin.tx_fileupload_pi1.checkExt = 1
plugin.tx_fileupload_pi1.extExclude = exe,php,php3
plugin.tx_fileupload_pi1.extInclude = *
plugin.tx_fileupload_pi1.maxsize = 50000
plugin.tx_fileupload_pi1.path = fileadmin/mitglieder/userupload
plugin.tx_fileupload_pi1.noOverwrite = 1

Die Schreibrechte für den Ordner sind alle gesetzt.

Habe schon überall nach einer Lösung gesucht und leider nichts gefunden.
Bin für alle Tipps dankbar...

gruß
Manfredo

cow ·

Hallo manfredo,
ich habe das selbe Problem.
Kann es sein das du auch Frames einsetzt?
Weil damit hat die Extension anscheinend Probleme.

Falls du schon eine Lösung hast, melde dich doch bitte.

Ich werde auch nach einer Lösung suchen.

mfg
TK

manfredo ·

Hallo,

Ja, jede Menge Frames... 🙁

Sorry, leider noch keine Lösung - (bin voll mit Arbeit und nur wenig Zeit) - wenn ich wieder mehr Zeit und evt. eine Lösung gefunden habe sag ich bescheid.

gruß
Manfred

cow ·

Hallo Manfredo,
ich habe eine Lösung gefunden.

Ich habe ein wenig im Code der Extension rumgefummelt.

Du musst einfach den Code mit diesem ersetzen:

/***************************************************************

* Copyright notice

*

* (c) 2003 Mads Brunn (brunn@mail.dk)

* All rights reserved

*

* This script is part of the Typo3 project. The Typo3 project is

* free software; you can redistribute it and/or modify

* it under the terms of the GNU General Public License as published by

* the Free Software Foundation; either version 2 of the License, or

* (at your option) any later version.

*

* The GNU General Public License can be found at

* http://www.gnu.org/copyleft/gpl.html.

*

* This script is distributed in the hope that it will be useful,

* but WITHOUT ANY WARRANTY; without even the implied warranty of

* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

* GNU General Public License for more details.

*

* This copyright notice MUST APPEAR in all copies of the script!

***************************************************************/

/**

* Plugin 'Upload' for the 'fileupload' extension.

*

* @author Mads Brunn <brunn@mail.dk>

*/

require_once(PATH_tslib."class.tslib_pibase.php");

class tx_fileupload_pi1 extends tslib_pibase {

var $prefixId = "tx_fileupload_pi1"; // Same as class name

var $scriptRelPath = "pi1/class.tx_fileupload_pi1.php"; // Path to this script relative to the extension dir.

var $extKey = "fileupload"; // The extension key.

var $maxsize;

var $uploadid = 'userfile';

/**

* [Put your description here]

*/

function main($content,$conf) {

$GLOBALS["TSFE"]->set_no_cache();

$this->conf=$conf;

file://debug($this->conf);

$this->maxsize=$this->conf['maxsize']?$this->conf['maxsize']:100000;

$this->pi_setPiVarDefaults();

$this->pi_loadLL();

$content='';

if($_POST['action']=='Upload'){

$content.=$this->handleUpload();

}

$content.=$this->displayUploadForm();

return $this->pi_wrapInBaseClass($content);

}

function displayUploadForm(){

$content=' <form enctype="multipart/form-data" action=

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"'.$this->pi_getPageLink($GLOBALS["TSFE"]->getStorageSiterootPids()).'" method="POST" target="'.$this->conf['target'].'">

<input type="hidden" name="MAX_FILE_SIZE" value="'.$this->maxsize.'">

<input name="'.$this->uploadid.'" type="file">

<input type="hidden" name="no_cache" value="1">

<input type="submit" name="action" value="'.$this->pi_getLL('submitupload').'">

</form>';

return $content;

}

function handleUpload(){

global $TYPO3_CONF_VARS;

$content='';

$uploaddir = is_dir($this->conf['path'])?$this->conf['path']:$TYPO3_CONF_VARS['BE']['fileadminDir'];

$uploadfile = $uploaddir.$_FILES[$this->uploadid]['name'];

if(is_file($uploadfile) && $this->conf['noOverwrite']){//file already exists?

return '

'.$this->pi_getLL('error.exist').'

';

}

if($this->fileTooBig($_FILES[$this->uploadid]['size'])){

$content.='

'.$this->pi_getLL('error.toobig').'

';

}

if(!$this->mimeAllowed($_FILES['userfile']['type'])){ file://mimetype allowed?

return '

'.$this->pi_getLL('error.mimenotallowed').$_FILES['userfile']['type'].'

';

}

if(!$this->extAllowed($_FILES[$this->uploadid]['name'])){ file://extension allowed?

return '

'.$this->pi_getLL('error.extensionnotallowed').'

';

}

if(move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {//succes!

return '

'.$this->pi_getLL('uploadsuccesfull').'

';

} else {

return $this->handleError($_FILES[$this->uploadid]['error']);

}

return "jo kommt an";

// $content;

}

function handleError($error){

$content='';

switch ($error){

case 0:

break;

case 1:

case 2:

$content.='

'.$this->pi_getLL('error.toobig').'

';

break;

case 3:

$content.='

'.$this->pi_getLL('error.partial').'

';

break;

case 4:

$content.='

'.$this->pi_getLL('error.nofile').'

';

break;

default:

$content.='

'.$this->pi_getLL('error.unknown').'

';

}

return $content;

}

function mimeAllowed($mime){

if(!($this->conf['checkMime'])) return TRUE; file://all mimetypes allowed

$includelist = explode(",",$this->conf['mimeInclude']);

$excludelist = explode(",",$this->conf['mimeExclude']); file://overrides includelist

file://debug($excludelist);

file://debug($includelist);

return ( (in_array($mime,$includelist) || in_array('*',$includelist)) && (!in_array($mime,$excludelist)) );

}

function extAllowed($filename){

if(!($this->conf['checkExt'])) return TRUE; file://all extensions allowed

$includelist = explode(",",$this->conf['extInclude']);

$excludelist = explode(",",$this->conf['extExclude']) ; file://overrides includelist

file://debug($excludelist);

file://debug($includelist);

$extension='';

if($extension=strstr($filename,'.')){

$extension=substr($extension, 1);

return ((in_array($extension,$includelist) || in_array('*',$includelist)) && (!in_array($extension,$excludelist)));

} else {

return FALSE;

}

}

function fileTooBig($filesize){

return $filesize > $this->maxsize;

}

}

if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/fileupload/pi1/class.tx_fileupload_pi1.php"]) {

include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/fileupload/pi1/class.tx_fileupload_pi1.php"]);

}

?>

manfredo ·

hi cow,

yeah! vielen Dank!

Es läuft jetzt auch bei mir, allerdings hat die Extension schwierigkeiten wenn der Pfad zu lang ist, erst wenn man die Files in einem Ordner unterhalb von Fileadmin anlegt funktioniert die Sache.

Also: "fileadmin/userupload/" -> bei "fileadmin/blablabla/userupload/" geht es wieder nicht.

Ich poste hier noch mal den Code von Dir zum besseren kopieren.

<?php
/***************************************************************
*  Copyright notice
*  
*  (c) 2003 Mads Brunn (brunn@mail.dk)
*  All rights reserved
*
*  This script is part of the Typo3 project. The Typo3 project is 
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
* 
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
* 
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/** 
 * Plugin 'Upload' for the 'fileupload' extension.
 *
 * @author	Mads Brunn <brunn@mail.dk>
 */


require_once(PATH_tslib."class.tslib_pibase.php");

class tx_fileupload_pi1 extends tslib_pibase {
	var $prefixId = "tx_fileupload_pi1";		// Same as class name
	var $scriptRelPath = "pi1/class.tx_fileupload_pi1.php";	// Path to this script relative to the extension dir.
	var $extKey = "fileupload";	// The extension key.
	
	var $maxsize;
	var $uploadid = 'userfile';
	
	/**
	 * [Put your description here]
	 */
	function main($content,$conf) { 
		$GLOBALS["TSFE"]->set_no_cache(); 
		$this->conf=$conf; 
		//debug($this->conf); 
		$this->maxsize=$this->conf['maxsize']?$this->conf['maxsize']:5000000; 
		$this->pi_setPiVarDefaults(); 
		$this->pi_loadLL(); 
		$content=''; 
		if($_POST['action']=='Upload'){ 
			$content.=$this->handleUpload(); 
		} 
		$content.=$this->displayUploadForm(); 
	return $this->pi_wrapInBaseClass($content); 
	} 

	function displayUploadForm(){ 
		$content='  <form enctype="multipart/form-data" action="'.$this->pi_getPageLink($GLOBALS["TSFE"]->getStorageSiterootPids()).'" method="POST" target="'.$this->conf['target'].'"> 
				    <input type="hidden" name="MAX_FILE_SIZE" value="'.$this->maxsize.'"> 
					<input name="'.$this->uploadid.'" type="file"> 
					<input type="hidden" name="no_cache" value="1"> 
					<input type="submit" name="action" value="'.$this->pi_getLL('submitupload').'"> 
					</form>'; 
		return $content; 
	} 
	
	function handleUpload(){ 
		global $TYPO3_CONF_VARS; 
		$content=''; 
		$uploaddir = is_dir($this->conf['path'])?$this->conf['path']:$TYPO3_CONF_VARS['BE']['fileadminDir']; 
		$uploadfile = $uploaddir.$_FILES[$this->uploadid]['name']; 
		if(is_file($uploadfile) && $this->conf['noOverwrite']){//file already exists? 
			return '<p>'.$this->pi_getLL('error.exist').'</p>'; 
		} 

		if($this->fileTooBig($_FILES[$this->uploadid]['size'])){ 
			$content.='<p>'.$this->pi_getLL('error.toobig').'</p>'; 
		} 
		if(!$this->mimeAllowed($_FILES['userfile']['type'])){ //mimetype allowed? 
			return '<p>'.$this->pi_getLL('error.mimenotallowed').$_FILES['userfile']['type'].'</p>'; 
		} 
		if(!$this->extAllowed($_FILES[$this->uploadid]['name'])){ //extension allowed? 
			return '<p>'.$this->pi_getLL('error.extensionnotallowed').'</p>'; 
		} 

		if(move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {//succes! 
			return '<p>'.$this->pi_getLL('uploadsuccesfull').'</p>'; 
		} else { 
			return $this->handleError($_FILES[$this->uploadid]['error']); 
		} 
		return "jo kommt an"; 
		// $content; 
	} 
	
	function handleError($error){ 
		$content=''; 
		switch ($error){ 
			case 0: 
			break; 
			case 1: 
			case 2: 
					$content.=' '.$this->pi_getLL('error.toobig').' '; 
					break; 
			case 3: 
					$content.=' '.$this->pi_getLL('error.partial').' '; 
					break; 
			case 4: 
					$content.=' '.$this->pi_getLL('error.nofile').' '; 
					break; 
			default: 
					$content.=' '.$this->pi_getLL('error.unknown').' '; 
		} 
		return $content; 
	} 
	
	
	
	function mimeAllowed($mime){ 
		if(!($this->conf['checkMime'])) return TRUE; //all mimetypes allowed 
		$includelist = explode(",",$this->conf['mimeInclude']); 
		$excludelist = explode(",",$this->conf['mimeExclude']); //overrides includelist 
		//debug($excludelist); 
		//debug($includelist); 
		return ( (in_array($mime,$includelist) || in_array('*',$includelist)) && (!in_array($mime,$excludelist)) ); 
	} 
		
	
	function extAllowed($filename){ 
		if(!($this->conf['checkExt'])) return TRUE; //all extensions allowed 
		$includelist = explode(",",$this->conf['extInclude']); 
		$excludelist = explode(",",$this->conf['extExclude']) ; //overrides includelist 
		//debug($excludelist); 
		//debug($includelist); 
		$extension=''; 
			if($extension=strstr($filename,'.')){ 
				$extension=substr($extension, 1); 
			return ((in_array($extension,$includelist) || in_array('*',$includelist)) && (!in_array($extension,$excludelist))); 
			} else { 
			return FALSE; 
			} 
	} 
	
	function fileTooBig($filesize){ 
		return $filesize > $this->maxsize; 
		} 
	} 

if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/fileupload/pi1/class.tx_fileupload_pi1.php"]) { 
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/fileupload/pi1/class.tx_fileupload_pi1.php"]); 
} 

?>

schönes Wochenende...

manfredo