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

L

latin0511

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!
 
G

Gunnar Hjalmarsson

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.
 
L

latin0511

Gunnar said:
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 $!.
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.
 
A

A. Sinan Unur

(e-mail address removed) wrote in
....


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
 
L

latin0511

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.
 
G

Gunnar Hjalmarsson

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"
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top