PHP Web Service Problem

Discussion in 'PHP' started by 2mk_atspace, Dec 1, 2007.

  1. #1
    i create web service with PHP and i have the following problem ;
    1. I create upload form, but $_FILES['file1']['name']; did't work.
    note :i can get $file, but when i try to get file name it didn't work.

    2. I create login form, and session didn't work too.
     
    2mk_atspace, Dec 1, 2007 IP
  2. thenetninja

    thenetninja Peon

    Messages:
    314
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    OK i am guessing you are trying to upload a file and store it in a directory. If this is the case, try this for an example:

    copy($_FILES['file1']['tmp_name'],"subdir/".$_FILES['file1']['name']);

    The $_FILES array contains only information about the uploaded file, not the actual file itself.

    tmp_name contains the location of the uploaded file, and this is why you copy it from tmp_name to where you want it stored. In the case of images you can even run imagejpeg or imagecreatefromjpeg with the value of tmp_name.

    2. For sessions make sure you have called session_start(); at the beginning of the script (There can be NO OUTPUT prior to session_start(); or you will get a headers error).

    Hope this helps, if not you will need to be more specific about the problems you are getting. Possibly some example code would help too.
     
    thenetninja, Dec 1, 2007 IP
  3. 2mk_atspace

    2mk_atspace Well-Known Member

    Messages:
    317
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #3
    1. That's not the problem if is store $_FILES['file1']['name'] in $filea
    $filea=$_FILES['file1']['name'] and and echo "$filea", it will no result, so that's why i say that $_FILES['file1']['name'] didn't work.

    2. i has already do that but not working.

    Note : All working without web service, but when i convert it to web service upload file and login didn't work.
     
    2mk_atspace, Dec 1, 2007 IP
  4. decepti0n

    decepti0n Peon

    Messages:
    519
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Is :

    1. The form "enctype" multipart/form-data? Otherwise it won't upload
    2. Does the file input field have the name "file1"?
     
    decepti0n, Dec 1, 2007 IP
  5. thenetninja

    thenetninja Peon

    Messages:
    314
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Good pickup, i was about to say that when i saw your post
     
    thenetninja, Dec 1, 2007 IP