Re: question about post zip file

Giganews Newsgroups
Subject: Re: question about post zip file
Posted by:  Remy Lebeau \(Indy Team\) (no.spam@no.spam.com)
Date: Thu, 1 Nov 2007

"Alexandre" <alexandrepires20…@yahoo.com.br> wrote in message
news:794D0EFA793BE340alexandrepires20…@yahoo.com.br...

> I am trying upload a zip file with TidHttp, but my code dont work:

Just saying that it doesn't work says nothing about the actual problem you
are having with it.  You need to be more specific.  What exactly is going
wrong with it?  Have you tried debugging the PHP code at all to see if the
data is even arriving?  There have been known bugs in PHP's file upload
capabilities, especially if the source and destination folders are on
different file systems.  Have you checked for all available fixes for PHP?

> Strm.AddFile('file', 'c:\teste.zip','multipart/form-data');

You are using the wrong ContentType for the file.  That is the ContentType
that needs to be used for the actual HTTP request (which TIdHTTP will handle
internally for you), not for the individual file.  Use the
GetMimeTypeFromFile() function to get the correct ContentType for the file,
ie:

    Strm.AddFile('file', 'c:\teste.zip',
GetMimeTypeFromFile('c:\teste.zip'));

> PHP code is (uploadarq.php):

Try this:

    <?
    if(isset($_FILES['file']))
    {
        $arquivo = $_FILES['file'];
        $ziparq_dir = 'Pedidos/' . $arquivo['name'];
        if(move_uploaded_file($arquivo['tmp_name'], $ziparq_dir))
            echo "ok";
        else
            echo "uploaded file was not moved";
    }
    else
        echo "uploaded file is not available";
    ?>

Gambit

Replies

In response to

question about post zip file posted by Alexandre on Thu, 1 Nov 2007