Seite 1 von 1

[Hilfe] ACP Upload Mod

Verfasst: 06.03.2005 12:50
von Dav1d
Hallo,

ich möchte für mein Forum einen Upload Mod fürs ACP in dem die Admins Dateien hochladen können ohne FTP-Zugang zu haben. Also eigentlich ein ganz einfacher Upload Mod habe aber Probleme, da ich micht nicht so mit Php auskenne und mehr oder weniger Codeschnipsel zusammenkopiert habe.

admin/admin_upload.php

Code: Alles auswählen

<?php

define('IN_PHPBB', 1);


if( !empty($setmodules) )
{
	$filename = basename(__FILE__);
	$module['General']['Upload'] = $filename;
	return;
}

$phpbb_root_path = "./../";
require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx);

	$template->set_filenames(array(
		"body" => "admin/upload.tpl")
	);

	$template->assign_vars(array(
		"L_UPLOAD_TITLE" => $lang['upload_title'],
		"L_UPLOAD_DESC" => $lang['upload_desc'],
		"L_UPLOAD_HEAD" => $lang['upload_head'],
	);
		$template->pparse("body");


include('./page_footer_admin.'.$phpEx);

?>
admin/admin_upload_send.php

Code: Alles auswählen

<?php
define('IN_PHPBB', 1);

if( !empty($setmodules) )
{
	$filename = basename(__FILE__);
	$module['General']['Upload'] = $filename;
	return;
}

$phpbb_root_path = "./../";
require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx);

$dateityp = GetImageSize($_FILES['upload']['tmp_name']);
if($dateityp[2] != 0)
   {

   if($_FILES['upload']['size'] <  102400)
      {
      move_uploaded_file($_FILES['upload']['tmp_name'], "upload/".$_FILES['upload']['name']);
      echo "{L_UPLOAD_SUCCESS}";
      }

   else
      {
         echo "{L_UPLOAD_ERROR_SIZE}";
      }

    }

else
    {
    echo "{L_UPLOAD_ERROR_TYPE}";
    }

	$template->set_filenames(array(
		"body" => "admin/upload.tpl")
	);

	$template->assign_vars(array(
		"L_UPLOAD_SUCCESS" => $lang['upload_success'],
		"L_UPLOAD_ERROR_SIZE" => $lang['upload_error_size'],
		"L_UPLOAD_ERROR_TYPE" => $lang['upload_error_type'],
	);
		$template->pparse("body");

include('./page_footer_admin.'.$phpEx);
?>
templates/subSilver/admin/upload.tpl

Code: Alles auswählen

<h1>{L_UPLOAD_TITLE}</h1>

<p>{L_UPLOAD_DESC}</p>
	
<form method="post" enctype="multipart/form-data" action="admin_upload_send.php"><table cellspacing="1" cellpadding="4" border="0" align="center" class="forumline">
	<tr>
		<th class="thHead">{L_UPLOAD_HEAD}</th>
	</tr>
	<tr>
		<td>
			<table cellspacing="0" cellpadding="5" border="0" align="center">
				<tr>
					<td class="row1" align="center"><input name="upload" type="file" size="47"></td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td class="catBottom" colspan="5" align="center"><input type="submit" value="Upload"></td>
	</tr>
</table></form>
Sprachvariablen sind auch eingetragen. Aber immer wenn ich eine Datei uploade werde ich auf die index.php des Forums geleitet. Wo ist der Fehler? Vielen Dank im vorraus.

Gruß

Dav1d

Lösung

Verfasst: 06.03.2005 13:49
von gloriosa
Hallo,
warum nimmst Du nicht gleich den Upload Mod von www.awsw.de ???

Verfasst: 06.03.2005 14:40
von Leuchte
Versuch mal statt

Code: Alles auswählen

action="admin_upload_send.php"
dieses

Code: Alles auswählen

action="{S_UPLOAD_ACTION}"
und in der admin_upload.php statt (was eigentlich einen Fehler aufrufen müsste)

Code: Alles auswählen

      "L_UPLOAD_HEAD" => $lang['upload_head'], 
   );
dieses

Code: Alles auswählen

      "L_UPLOAD_HEAD" => $lang['upload_head'],
      "S_UPLOAD_ACTION" => append_sid("admin_upload_send.$phpEx"))
   );

Verfasst: 06.03.2005 15:20
von Dav1d
@ Leuchte
Funktioniert! Vielen Dank, hab mich gestern Stunden damit rumgeärgert aber jetzt hab ich das Problem kapiert. Nochmal Danke für die schnelle Antwort.

@ gloriosa
Hab mir das Script von www.awsw.de noch nicht angeguckt, da es jetzt aber bei meinem Forum funktioniert brauch ich es nicht mehr. Trotzdem Danke für den Rat.

Gruß

Dav1d