Uploaden wie?

Interritor

Erfahrenes Mitglied
Hi!
Ich hab ein problem und zwar wollte ich ein klein Upload script schreiben mit dem man eine Datei in ein Verzeichnis uploaden kann. Aber ich weiss echt nicht wie ich das mcahen soll hat jemand vielleicht einen code für mich oder so? wäre echt nett?
:]
 
ok, du willst ein program schreiben das dateien, ich nehme mal an
auf einen FTP-Server uploadet.
zuerst musst du die FTP-Commands kennen:
----------------------------
Befehl: Funktion:
----------------------------


! :Escape zur Shell (zurück mit exit)

$ :Makro ausführen

? :Hilfe ausgeben

account :Account Kommando zum Server schicken

append :An Datei anhängen

ascii :ASCII-Übertragungs-Modus einstellen

bell :Tonausgabe wenn Kommando ausgeführt

binary :Binär-Übertragungs-Modus einstellen

bye :FTP-Sitzung beenden und Verlassen

cd :Remote Arbeitsverzeichnis wechseln

cdup :Remote Arbeitsverzeichnis zum Erlternverz. wechseln

chmod :Rechte an Remote-Datei ändern

close :Verbindung zum Remote-Host trennen

cr :Umschaltung

debug :Umschaltung und Setzen des Debugger-Modus

del bzw. delete :Remote-Datei löschen

dir :Inhalt von Remote-Verzeichnis anzeigen

disconnect :FTP-Sitzung abbrechen

form :FTP-Format setzen

get :Datei empfangen

help :Hilfe Anzeigen

idle :Systembereitschaft bei Nichteingabe Zeitlimit 900-7200Sek

lcd :Lokales Arbeitsverzeichnis wechseln

ls :Inhalt des Remote-Verzeichnisses anzeigen

macdef :Makro definieren

mdelete :mehrere Dateien löschen

mdir :zeigt Inhalt mehrerer Remote-Verzeichnisse an

mget :mehrere Dateien empfangen

mkdir :Verzeichnis auf Remote-Maschine erstellen

mls :zeigt Inhalt mehrerer Remote-Verzeichnisse an

mode :Setzt FTP-Modus

modtime :Zeigt Zeit der letzten Änderung einer Remote-Datei

mput :Mehrere Dateien senden

newer :empfängt Remote-Datei wenn neuer als lokale Datei

nlist :zeigt Inhalt von Remote-Verzeichnissen

open :Verbindung zum Remote-Host aufbauen

prompt :erzwingt interaktiven Prompt für mehrere Kommandos

put :Datei senden

pwd :Arbeitsverzeichnis auf Remote-Maschine anzeigen

quit :FTP beenden

recv :Datei empfangen

rename :Dateiname ändern

restart :Neustart von File-Transfer

rhelp :Hilfe vom Remote Server

rmdir :Verzeichnis auf Remote entfernen

rstatus :Statusanzeige der Remote-Maschine

send :Datei senden

size :Dateigröße von Remote-Datei

status :Aktuellen Status anzeigen

struct :FTP-Struktur setzen

system :Anzeige des Remote-Systemtypes

tenex :Setzt Tenex Dateiübertragungs-Typ

type :FTP-Typ setzen

user :Neue User-Information senden

verbose :Umschalten auf Verbose Modus

--------------------------------------------------------

nun brauchst du eine geeignete programmiersprache wie perl, c, oder php mit dem du zu einem FTP-Server connecten kannst aber die entscheidung überlass ich dir :)
ich hoffe ich konnte helfen
ciao
 
high!

ähh.. ich glaub das war wohl anders gemeint. erstmal tuts ein einfaches form auf html seite mit <input type=file> beim form mußt du drauf achten den richtigen content-type zu setzen. ich hab das damals über selfhtml gefunden.
jetzt mußt du serverseitig hergehen und das file empfangen und entsprechend speichern, dass hängt davon ab in welcher sprache du das machst (perl o.a.). einfach mal bei deja.com mit den entsprechenden begriffen suchen, da wirst du bestimmt fündig (so wars bei mir zumindest)

gruß The-spY
 
mmhm

...mit java gehts meineswissens nicht(?)... aber schau mal HIER in der PHP section nach... da findest du schon auf der ersten seite den beitrag "FileUpload mit JAVA?????????" ...der hilft!!!

ciao
 
aber von meinem Server wird kein PHP unterstüzt...einer ne Lösung oder nen Link zu nem Script?
 
Natürlich geht das mit Java

Man kann sich mit Java auf einem bestimmten FTP server einloggen soweit man den Benutzernamen un sein Kennwort kennt. Dazu gibts im Internet diverse fertige Klassen wo man nurnoch ein paar zeilen in seinem eigenen Programm tippen muss um z.B. eine Datei hoch oder runterzuladen!!!

Ich hab hier mal so ne externe Klasse (GEHÖRT NICHT MIER):

/**
* File: FTPConnection.java
* Author: Bret Taylor <btaylor@cs.stanford.edu>
* ---------------------------------------------
* $Id$
* ---------------------------------------------
* Parts of this code were adopted from a variety of other FTP classes the
* author has encountered that he was not completely satisfied with. If you
* think more thanks are due to any particular author than is given, please
* let him know. With that caveat, this class can be freely distributed and
* modified as long as Bret Taylor is given credit in the source code comments.
*/

import java.io.*;
import java.net.*;
import java.util.*;

/**
* <p>A wrapper for the network and command protocols needed for the most common
* FTP commands. Standard usage looks something like this:</p>
* <pre> FTPConnection connection = new FTPConnection();
* try {
* if (connection.connect(host)) {
* if (connection.login(username, password)) {
* connection.downloadFile(serverFileName);
* connection.uploadFile(localFileName);
* }
* connection.disconnect();
* }
* } catch (UnknownHostException e) {
* // handle unknown host
* } catch (IOException e) {
* // handle I/O exception
* }</pre>
* <p>Most FTP commands are wrapped by easy-to-use methods, but in case clients
* need more flexibility, you can execute commands directly using the methods
* <a href="#executeCommand(java.lang.String)">executeCommand</a> and
* <a href="#executeDataCommand(java.lang.String, java.io_OutputStream)">executeDataCommand</a>,
* the latter of which is used for commands that require an open data port.</p>
*
* @author Bret Taylor
* @version 1.0
*/
public class FTPConnection extends Object {

/**
* If this flag is on, we print out debugging information to stdout during
* execution. Useful for debugging the FTP class and seeing the server's
* responses directly.
*/
private static boolean PRINT_DEBUG_INFO = false;

/**
* Connects to the given FTP host on port 21, the default FTP port.
*/
public boolean connect(String host)
throws UnknownHostException, IOException
{
return connect(host, 21);
}

/**
* Connects to the given FTP host on the given port.
*/
public boolean connect(String host, int port)
throws UnknownHostException, IOException
{
connectionSocket = new Socket(host, port);
outputStream = new PrintStream(connectionSocket.getOutputStream());
inputStream = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));

if (!isPositiveCompleteResponse(getServerReply())){
disconnect();
return false;
}

return true;
}

/**
* Disconnects from the host to which we are currently connected.
*/
public void disconnect()
{
if (outputStream != null) {
try {
outputStream.close();
inputStream.close();
connectionSocket.close();
} catch (IOException e) {}

outputStream = null;
inputStream = null;
connectionSocket = null;
}
}

/**
* Wrapper for the commands <code>user [username]</code> and <code>pass
* [password]</code>.
*/
public boolean login(String username, String password)
throws IOException
{
int response = executeCommand("user " + username);
if (!isPositiveIntermediateResponse(response)) return false;
response = executeCommand("pass " + password);
return isPositiveCompleteResponse(response);
}

/**
* Wrapper for the command <code>cwd [directory]</code>.
*/
public boolean changeDirectory(String directory)
throws IOException
{
int response = executeCommand("cwd " + directory);
return isPositiveCompleteResponse(response);
}

/**
* Wrapper for the commands <code>rnfr [oldName]</code> and <code>rnto
* [newName]</code>.
*/
public boolean renameFile(String oldName, String newName)
throws IOException
{
int response = executeCommand("rnfr " + oldName);
if (!isPositiveIntermediateResponse(response)) return false;
response = executeCommand("rnto " + newName);
return isPositiveCompleteResponse(response);
}

/**
* Wrapper for the command <code>mkd [directory]</code>.
*/
public boolean makeDirectory(String directory)
throws IOException
{
int response = executeCommand("mkd " + directory);
return isPositiveCompleteResponse(response);
}

/**
* Wrapper for the command <code>rmd [directory]</code>.
*/
public boolean removeDirectory(String directory)
throws IOException
{
int response = executeCommand("rmd " + directory);
return isPositiveCompleteResponse(response);
}

/**
* Wrapper for the command <code>cdup</code>.
*/
public boolean parentDirectory()
throws IOException
{
int response = executeCommand("cdup");
return isPositiveCompleteResponse(response);
}

/**
* Wrapper for the command <code>dele [fileName]</code>.
*/
public boolean deleteFile(String fileName)
throws IOException
{
int response = executeCommand("dele " + fileName);
return isPositiveCompleteResponse(response);
}

/**
* Wrapper for the command <code>pwd</code>.
*/
public String getCurrentDirectory()
throws IOException
{
String response = getExecutionResponse("pwd");
StringTokenizer strtok = new StringTokenizer(response);

// Get rid of the first token, which is the return code
if (strtok.countTokens() < 2) return null;
strtok.nextToken();
String directoryName = strtok.nextToken();

// Most servers surround the directory name with quotation marks
int strlen = directoryName.length();
if (strlen == 0) return null;
if (directoryName.charAt(0) == '\"') {
directoryName = directoryName.substring(1);
strlen--;
}
if (directoryName.charAt(strlen - 1) == '\"')
return directoryName.substring(0, strlen - 1);
return directoryName;
}

/**
* Wrapper for the command <code>syst</code>.
*/
public String getSystemType()
throws IOException
{
return excludeCode(getExecutionResponse("syst"));
}

/**
* Wrapper for the command <code>mdtm [fileName]</code>. If the file does
* not exist, we return -1;
*/
public long getModificationTime(String fileName)
throws IOException
{
String response = excludeCode(getExecutionResponse("mdtm " + fileName));
try {
return Long.parseLong(response);
} catch (Exception e) {
return -1L;
}
}

/**
 
Der Code geht noch weiter....


Hab leider keine Zeit 3 Minuten noch zu waren Sorry


Aber such einfach mal bei Google oder lycos
 
Zurück