move_uploaded_file | kein filetransfer

S

sevY

hi,

was ist hier falsch? sowohl online als auch offline funktioniert das script nicht. es wird also nicht an meiner lokalen config liegen.

PHP:
<html>
<head>
<title>motul Datenbank Administration | Mediadaten</title>
<link rel=stylesheet href=../admin.css>
<meta-http-equiv=expires content=0>
<meta-http-equiv=Pragma content=no-cache>
</head>
<body>
<?php
require_once("../../_config.php");
$db_contact="motul_media"; 
if ($_POST[action]==upload)
    {   
    $logopfad="media/img/logo/";
    $downloadpfad="media/downloads/";
    $logoinsert=$logopfad.$_FILES['motul_media_navigation_new']['name'];
    $downloadinsert=$downloadpfad.$_FILES['motul_media_downloadlink_new']['name'];
    if (!$_EMPTY[motul_media_navigation_new] AND eregi("(jpg|jpeg)$",$_FILES['motul_media_navigation_new']['name']))
    {
    move_uploaded_file($_FILES['motul_media_navigation_new']['name'],$logopfad);
    }
    else
    {
    echo "Es wurde kein Medialogo hinzugef&uuml;gt. Sie haben keine Datei ausgew&auml;hlt oder keinen g&uuml;ltigen Dateityp (non-progressives jpg,jpeg) gew&auml;hlt.<p>";
    }
    if(!$_EMPTY[motul_media_downloadlink_new])
    {
    move_uploaded_file($_FILES['motul_media_downloadlink_new']['name'],$downloadpfad);    
    }
    else
    {
    echo "Es wurde kein Downloadobjekt hinzugef&uuml;gt. Sie haben keine Datei ausgew&auml;hlt.<p>";
    }
    $read=mysql_query("select motul_media_shorttext from $db_contact where ID_motul_media = '1'",$handler);
    $a=mysql_fetch_array($read);
    mysql_db_query($db_dbase,"insert into $db_contact (motul_media_shorttext,motul_media_navigation,motul_media_downloadlink,motul_media_downloadlink_name) VALUES ('$a[motul_media_shorttext]','$logoinsert','$downloadinsert','$_POST[motul_media_downloadlink_name_new]')");
    }       
?>
<form enctype=multipart/form-data action=motul_media_new.php method=post>
    <input type=hidden name=action value=upload>
        <b>Medialogo:</b><br><p>
            <input type=file name=motul_media_navigation_new><p>
        <b>Downloadobjekt:</b><p>
            <input type=file name=motul_media_downloadlink_new><p>
        <b>Bezeichnung des Downloadlinks:</b><p>
            <input type=text name=motul_media_downloadlink_name_new maxsize=60 size=55 value=DOWNLOAD&nbsp;PDF><br><p>    
    <input type=submit value=hinzuf&uuml;gen>
</form>
<a href=motul_media_new.php target=self>reset</a>
</body>
</html>

Die Pfade werden alle in die DB eingetragen, alles funktioniert. Nur leider wird keine Datei kopiert. Ordnerrechte sind proforma auf 777.

Jemand eine Ahnung?


Liebe Grüße

Coffee
 
Zuletzt bearbeitet von einem Moderator:
Haudi,

na wieder am Programmieren?

Zum Thema ... ich kann auf den ersten Blick leider auch keinen Fehler ent-
decken. Wird denn gar keine Fehlermeldung ausgegeben? Schreib' mal unter
den Befehl "move_uploaded_file(...)" Folgendes:

PHP:
move_uploaded_file($_FILES['motul_media_downloadlink_new']['name'],$downloadpfad)
or die("Fehler");

Achte darauf, dass das Semikolon hinter dem "move" Befehl weg muss.
Weiterhin würde ich mir die beiden Variablen mal mit dem "echo" Befehl
ausgeben lassen - nur Testweise.


Gruß
 
PHP:
<html>
<head>
<title>motul Datenbank Administration | Mediadaten</title>
<link rel=stylesheet href=../admin.css>
<meta-http-equiv=expires content=0>
<meta-http-equiv=Pragma content=no-cache>
</head>
<body>
<?php
require_once("../../_config.php");
$db_contact="motul_media"; 
if ($_POST[action]=='upload')
    {   
    $logopfad="media/img/logo/";
    $downloadpfad="media/downloads/";
    $logoinsert=$logopfad.$_FILES['motul_media_navigation_new']['name'];
    $downloadinsert=$downloadpfad.$_FILES['motul_media_downloadlink_new']['name'];
    if(!empty($_FILES['motul_media_navigation_new']['name']) AND eregi("(jpg|jpeg)$",$_FILES['motul_media_navigation_new']['name']))
    {
    move_uploaded_file($_FILES['motul_media_navigation_new']['name'],"../../".$logopfad);
    }
    else
    {
    echo "Es wurde kein Medialogo hinzugef&uuml;gt. Sie haben keine Datei ausgew&auml;hlt oder keinen g&uuml;ltigen Dateityp (non-progressives jpg,jpeg) gew&auml;hlt.<p>";
    }
    if(!empty($_FILES['motul_media_downloadlink_new']['name']))
    {
    move_uploaded_file($_FILES['motul_media_downloadlink_new']['name'],"../../".$downloadpfad);    
    }
    else
    {
    echo "Es wurde kein Downloadobjekt hinzugef&uuml;gt. Sie haben keine Datei ausgew&auml;hlt.<p>";
    }
    $read=mysql_query("select motul_media_shorttext from $db_contact where ID_motul_media = '1'",$handler);
    $a=mysql_fetch_array($read);
    mysql_db_query($db_dbase,"insert into $db_contact (motul_media_shorttext,motul_media_navigation,motul_media_downloadlink,motul_media_downloadlink_name) VALUES ('$a[motul_media_shorttext]','$logoinsert','$downloadinsert','$_POST[motul_media_downloadlink_name_new]')");
    }       
?>
<form enctype=multipart/form-data action=motul_media_new.php method=post>
    <input type=hidden name=action value=upload>
        <b>Medialogo:</b><br><p>
            <input type=file name=motul_media_navigation_new><p>
        <b>Downloadobjekt:</b><p>
            <input type=file name=motul_media_downloadlink_new><p>
        <b>Bezeichnung des Downloadlinks:</b><p>
            <input type=text name=motul_media_downloadlink_name_new maxsize=60 size=55 value=DOWNLOAD&nbsp;PDF><br><p>    
    <input type=submit value=hinzuf&uuml;gen>
</form>
<a href=motul_media_new.php target=self>reset</a>
</body>
</html>

Das hier habe ich nochmal überarbeitet.

Wenn ich nun anstatt ['name'] -> ['tmp_name'] bei dem move_uploaded_file(); nehme, dann bekomme ich folgende Fehlermeldung:

Warning: move_uploaded_file(../../media/img/logo/): failed to open stream: Is a directory in/Library/WebServer/Documents/Aktuelle Auftragsarbeiten/motul/admin/sys/motul_media_new.php on line 20

Warning: move_uploaded_file(): Unable to move '/var/tmp/phppJVU3Q' to '../../media/img/logo/' in/Library/WebServer/Documents/Aktuelle Auftragsarbeiten/motul/admin/sys/motul_media_new.php on line 20


Jemand eine Ahnung was das bedeutet?


Das echo gibt aufjedenfall alle Variablen korrekt wieder.

Dein „or die“ gab allerdings einen Parse-Error.


Liebe Grüße

Yves
 
Hi, Lösung gefunden:

Wer konkatiniert, gewinnt :D

PHP:
move_uploaded_file($_FILES['motul_media_navigation_new']['tmp_name'],"../../".$logopfad.$_FILES['motul_media_navigation_new']['name']);


Liebe Grüße

Yves
 
Morgen! :D

Na da hast Du Dir ja schon selber geholfen. Das "or die()" sollte eigentlich
keinen Parse Error verursachen. Vielleicht hast Du das Semikolon hinter
dem "move_uploaded_file()" stehen gelassen. Will ich Dir aber auch nicht
unterstellen. ;)


Gruß
Delmar
 
Wegen des ParseErrors… ich hab via copy n paste dein Script kopiert. Komisch oder?

Liebe Grüße

Yves
 
Allerdings, da es bei mir funktioniert hat ... naja, soll vorkommen. :D
 
Hi,

ich schick dir einfach mal im Laufe des Tages mein Script. Funktioniert nun alles wunderbar, aber komisch ist das schon mit or die(); .
Liebe Grüße

Yves
 
Zurück
Oben Unten