Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> problem z pobraniem pola z formularza multiopart
mel
post
Post #1





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 7.04.2009

Ostrzeżenie: (0%)
-----


Witam,

wysyłam z kodu wiadomość do servera PHP.

kod po stronei clienta (java):

String message1 = "";

message1 += "--" + boundary + CrLf;
message1 += "Content-Disposition: form-data; name=\"user\"" +CrLf;
message1 += "Content-Type: text/plain" + CrLf;
message1 += CrLf;
message1 = "someuser" + CrLf;

message1 += "--" + boundary + CrLf;
message1 += "Content-Disposition: form-data; name=\"uploadedfile\"; filename=\"" + FILE + "\"" + CrLf;
message1 += "Content-Type: " + contentType + CrLf;
message1 += "Content-Transfer-Encoding: binary" + CrLf;
message1 += CrLf;

// the binary are sent between the messages in the multipart message

String message2 = "";
message2 += CrLf + "--" + boundary + "--" + CrLf;

To chyba jest odpowiednik tego kodu w HTMLu:
<form action="http://mojastona/index.php" enctype ="multipart/form-data" method="post">
<input type="file" name="uploadedfile">
<input type="submit" name="Wyslij plik">
<input type="hidden" name="user" value="someuser">
</form>


kod PHP:
if (!empty( $_POST['user'] ) )
{

$user = $_POST['user'];
}

// to upload files should be created path like this: users/user + temp_dir
$target_path = "uploads/"; // direction dir common for all users - test

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$plik_nazwa = basename( $_FILES['uploadedfile']['name'] );

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";

} else{
echo "There was an error uploading the file, please try again! : ".$plik_nazwa;
}

Problem jest taki, że $_POST['user'] nie przechowuje pola 'user.
Nie wiem już w czym problem. Czy żle definiuje wiadomość dla servera w cliencie,
czy może nie $_POSTem odbieram pole formularza ?

Pozdrawiam



Message dla servera jes ok. Jak zwykle bład po stronie programisty.
Sprawcą mojego rychłego osiwienia była ta linia:
message1 = "someuser" + CrLf;

Ten post edytował mel 8.04.2009, 09:13:51
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 14:17