Sunday, May 1, 2011

using the webclient to upload a file in post and the php to recive and handle file

how do i get the php to reconize that there is a file being uploaded to it by the vb webclient

current php code is this

if(count($_FILES)==1) {
    //move_uploaded_file  
    ( $_FILES[0]["tmp_name"]  , "./imgs/curdesktop.png"  );

    file_put_contents("./nin.txt",print_r($_FILES));
}

all it does right now is check the FILE array and supposed to print the attributes out into a text file. however the vb program says that the file is uploaded with no errors and the $_FILES array returns 1 which is invalid for that array

From stackoverflow
  • You have print_r() as a function which returns a value. Check first wat print_r really prints on the screen. (I think it does print it now already)

  • Try using var_export():

    file_put_contents("./nin.txt",var_export($_FILES,true));
    

    Passing true as the second argument will return the variable representation instead of outputing it, so the contents should write to the file.

  • Make that print_r($_FILES, true).

  • Its working thanks

0 comments:

Post a Comment