"Inappropriate ioctl for device" while upload()ing using CGI.pm

Discussion in 'Perl Misc' started by latin0511@gmail.com, Jul 1, 2006.

  1. Guest

    I'm using the procedural upload() function from CGI.pm.
    In this line:
    my $fd_file = upload( 'file' ) or die( "upload() ( $! )" );

    I encounter the weird-looking error:
    "Inappropriate ioctl for device".

    I don't understand what could be the problem. I did exactly like they
    say in the manual.
    Can you please help me solve this problem?

    Thanks a lot!
    , Jul 1, 2006
    #1
    1. Advertising

  2. wrote:
    > I'm using the procedural upload() function from CGI.pm.
    > In this line:
    > my $fd_file = upload( 'file' ) or die( "upload() ( $! )" );


    What makes you think that $! contains an appropriate error message if no
    file is uploaded?

    > I encounter the weird-looking error:
    > "Inappropriate ioctl for device".
    >
    > I don't understand what could be the problem. I did exactly like they
    > say in the manual.
    > Can you please help me solve this problem?


    Use the CPAN module CGI::UploadEasy.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Jul 1, 2006
    #2
    1. Advertising

  3. Guest

    Gunnar Hjalmarsson wrote:
    > wrote:
    > > I'm using the procedural upload() function from CGI.pm.
    > > In this line:
    > > my $fd_file = upload( 'file' ) or die( "upload() ( $! )" );

    >
    > What makes you think that $! contains an appropriate error message if no
    > file is uploaded?

    I check that param( 'file' ) exists before that line, if that's what
    you mean.
    I think that upload() is like open() in some aspect, thats why it
    should set $!.

    > > I encounter the weird-looking error:
    > > "Inappropriate ioctl for device".
    > >
    > > I don't understand what could be the problem. I did exactly like they
    > > say in the manual.
    > > Can you please help me solve this problem?

    >
    > Use the CPAN module CGI::UploadEasy.


    I can't do that. I want the program to generate a random name for every
    file uploaded, and using UploadEasy it looks impossible.
    In addition, UploadEasy is based on CGI.pm, and uses CGI.pm's upload()
    function too, so there is no reason why it should work.
    , Jul 1, 2006
    #3
  4. wrote in
    news::

    >
    > Gunnar Hjalmarsson wrote:
    >> wrote:
    >> > I'm using the procedural upload() function from CGI.pm.
    >> > In this line:
    >> > my $fd_file = upload( 'file' ) or die( "upload() ( $! )" );

    >>


    ....

    >> > Can you please help me solve this problem?

    >>
    >> Use the CPAN module CGI::UploadEasy.

    >
    > I can't do that. I want the program to generate a random name for
    > every file uploaded, and using UploadEasy it looks impossible.
    > In addition, UploadEasy is based on CGI.pm, and uses CGI.pm's upload()
    > function too, so there is no reason why it should work.


    I have not used Gunnar's module, however, I looked at the source code to
    learn from it. Looking at it again, I don't see why it should not work.

    On the other hand, I note that we have not seen any of your code, so we
    have no idea if your problem is really related to CGI.pm or your own
    code.

    If I were you, I would write a test script using CGI::UploadEasy, and
    see if the upload succeeds in the simple case. If it does, then you will
    have shown that the problem is related to your code.

    Regardless of wheter CGI::UploadEasy works for you, post a short but
    complete example exhibiting the problem.

    Sinan
    A. Sinan Unur, Jul 1, 2006
    #4
  5. Guest

    Thank you all! I've managed to fix it.
    The problem was that my form declaration in HTML looked like this:
    <form action="upload.pl" method="post">

    instead of:
    <form action="upload.pl" method="post" enctype="multipart/form-data">

    Thank you all for your time.
    , Jul 2, 2006
    #5
  6. wrote:
    > Thank you all! I've managed to fix it.


    Good.

    > The problem was that my form declaration in HTML looked like this:
    > <form action="upload.pl" method="post">
    >
    > instead of:
    > <form action="upload.pl" method="post" enctype="multipart/form-data">


    Can't help noticing thst with CGI::UploadEasy, the browser would have
    displayed the following error message:

    Error
    The content-type at file uploads shall be 'multipart/form-data'.
    Make sure that the 'FORM' tag includes the attribute:
    enctype="multipart/form-data"

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Jul 2, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. error while "free"ing memory

    , Feb 8, 2006, in forum: C Programming
    Replies:
    5
    Views:
    295
  2. Laszlo Nagy
    Replies:
    0
    Views:
    723
    Laszlo Nagy
    May 31, 2007
  3. gnewsgroup
    Replies:
    1
    Views:
    962
    gnewsgroup
    Jan 4, 2008
  4. Mamahita Sela
    Replies:
    1
    Views:
    473
  5. Une Bévue
    Replies:
    0
    Views:
    514
    Une Bévue
    Sep 7, 2008
Loading...

Share This Page