Professional Web Applications Themes

why doesn't this work? - PHP Development

See scripts below: I get zero sized files. and an error message in the logs like this: readline() on unopened filehandle at upload.cgi It seems that the follwing line is failing in my code +++ my $upload_filehandle = $query->upload("myfilename"); but this is almost exactly the same as the perldoc CGI docs sample. anyone? This is the upload script #!/usr/local/bin/perl use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser); $CGI::DISABLE_UPLOADS = 0; my $upload_dir = '/tmp/upload.txt; my $query = new CGI; my $filename = $query->param('myfilename'); print $filename; $filename =~ s/.*\/\(.*)/$1/; print $filename; my $upload_filehandle = $query->upload("myfilename"); open(UPLOADFILE, ">$upload_dir/$filename") or die $!; ...

  1. #1

    Default Why doesn't this work?

    See scripts below: I get zero sized files. and an error message in the logs
    like this: readline() on unopened filehandle at upload.cgi

    It seems that the follwing line is failing in my code

    +++ my $upload_filehandle = $query->upload("myfilename");

    but this is almost exactly the same as the perldoc CGI docs sample.

    anyone?


    This is the upload script
    #!/usr/local/bin/perl

    use strict;
    use warnings;

    use CGI;
    use CGI::Carp qw(fatalsToBrowser);

    $CGI::DISABLE_UPLOADS = 0;

    my $upload_dir = '/tmp/upload.txt;

    my $query = new CGI;
    my $filename = $query->param('myfilename');

    print $filename;

    $filename =~ s/.*\/\\(.*)/$1/;

    print $filename;

    my $upload_filehandle = $query->upload("myfilename");

    open(UPLOADFILE, ">$upload_dir/$filename") or die $!;

    binmode UPLOADFILE;

    while ( <$upload_filehandle> )
    {
    print UPLOADFILE;
    }
    close UPLOADFILE;
    print $query->header ( );
    jend Guest

  2. #2

    Default Re: Why doesn't this work?

    jend wrote:
    > See scripts below: I get zero sized files. and an error message in the logs
    > like this: readline() on unopened filehandle at upload.cgi
    >
    > It seems that the follwing line is failing in my code
    >
    > +++ my $upload_filehandle = $query->upload("myfilename");
    >
    > but this is almost exactly the same as the perldoc CGI docs sample.
    ....


    Quick dumb guess:

    > my $upload_filehandle = $query->upload("myfilename");
    $filename--------------------------------^^^^^^^^^^^^

    Your code is trying to upload the literal filename "myfilename". That's
    probably not the name of the file you actually want to upload.
    ....

    --
    Bob Walton

    Bob Walton Guest

  3. #3

    Default Re: Why doesn't this work?

    jend wrote:
    > See scripts below: I get zero sized files. and an error message in the logs
    > like this: readline() on unopened filehandle at upload.cgi
    > It seems that the follwing line is failing in my code
    > +++ my $upload_filehandle = $query->upload("myfilename");
    just another hint:
    how does your HTML, especially te form-tag, look like?
    does it contain enctype="multipart/form-data"?

    hth, tina
    --
    [url]http://www.tinita.de/[/url] \ enter__| |__the___ _ _ ___
    [url]http://Movies.tinita.de/[/url] \ / _` / _ \/ _ \ '_(_-< of
    [url]http://www.perlquotes.de/[/url] \ \ _,_\ __/\ __/_| /__/ perception
    - my mail address expires end of august 2003 -
    Tina Mueller Guest

  4. #4

    Default Why doesn't this work?

    Hi -

    I am trying to get this piece of script to work without any success. I am
    running this on W2K w/SP4 and IIS 5.0. I am using Windows Integrated
    Authentication and logging on as a Domain Admin.

    ' Create File System Object
    Set objFiles = Server.CreateObject("Scripting.FileSystemObject")

    ' Check for duplicate folder name
    If objFiles.FolderExists(strHomeDirectory)

    Then WScript.Echo "A home folder " & strHomeDirectory & " already exists. A
    new home folder will need to be created manually."

    Else

    'Create the User HomeDirectory - This works!
    objFiles.CreateFolder(strHomeDirectory)

    ChangeFolderSettings("AUserFolder")

    Sub ChangeFolderSettings(strLoginID)

    Dim cmdCacls
    Dim objWsShell
    Dim objWsRun

    cmdCacls = "cmd /c echo y| CACLS.EXE \\" & strServer & "\" &
    strStudentGradYear & "\" & strInit & "\" & strLoginID & " /e /g " &
    strLoginID & ":C"
    Set objWsShell = Server.CreateObject("WScript.Shell")
    ' IIS does not like this
    Set objWsRun = objWsShell.run(cmdCacls, 0, True)

    Set objWsShell = nothing
    Set objWsRun = nothing

    End Sub

    End If

    At the Set objWsRun = objWsShell.run(cmdCacls, 0, True) line IIS returns an
    error stating:

    Microsoft VBScript runtime (0x800A01A8)
    Object required: 'objWsShell.run(...)'

    The folder does get created sucessfully.

    Any help on this or other methods of setting folder permissions within an
    ASP page would be greatly appreciated.

    Thanks!!!

    Mike


    Mike Guest

  5. #5

    Default Re: Why doesn't this work?

    IIRC, and I haven't checked this, the run method returns a number indicating
    success (0) or error (any other value). Since the data type Long Integer is
    obviously NOT an object, you're getting the error because you're trying to
    "Set objWsRun = ... " instead of just letting "lngResult = ..."

    HTH, someone correct me if I'm wrong...

    --Boris

    "Mike" <mzehnerhotmail.com> wrote in message
    news:upCTBd%23dDHA.2304TK2MSFTNGP11.phx.gbl...
    > Hi -
    >
    > I am trying to get this piece of script to work without any success. I am
    > running this on W2K w/SP4 and IIS 5.0. I am using Windows Integrated
    > Authentication and logging on as a Domain Admin.
    >
    > ' Create File System Object
    > Set objFiles = Server.CreateObject("Scripting.FileSystemObject")
    >
    > ' Check for duplicate folder name
    > If objFiles.FolderExists(strHomeDirectory)
    >
    > Then WScript.Echo "A home folder " & strHomeDirectory & " already exists.
    A
    > new home folder will need to be created manually."
    >
    > Else
    >
    > 'Create the User HomeDirectory - This works!
    > objFiles.CreateFolder(strHomeDirectory)
    >
    > ChangeFolderSettings("AUserFolder")
    >
    > Sub ChangeFolderSettings(strLoginID)
    >
    > Dim cmdCacls
    > Dim objWsShell
    > Dim objWsRun
    >
    > cmdCacls = "cmd /c echo y| CACLS.EXE \\" & strServer & "\" &
    > strStudentGradYear & "\" & strInit & "\" & strLoginID & " /e /g " &
    > strLoginID & ":C"
    > Set objWsShell = Server.CreateObject("WScript.Shell")
    > ' IIS does not like this
    > Set objWsRun = objWsShell.run(cmdCacls, 0, True)
    >
    > Set objWsShell = nothing
    > Set objWsRun = nothing
    >
    > End Sub
    >
    > End If
    >
    > At the Set objWsRun = objWsShell.run(cmdCacls, 0, True) line IIS returns
    an
    > error stating:
    >
    > Microsoft VBScript runtime (0x800A01A8)
    > Object required: 'objWsShell.run(...)'
    >
    > The folder does get created sucessfully.
    >
    > Any help on this or other methods of setting folder permissions within an
    > ASP page would be greatly appreciated.
    >
    > Thanks!!!
    >
    > Mike
    >
    >

    Boris Nikolaevich Guest

  6. #6

    Default Re: Why doesn't this work?

    Thank you Boris.

    You were right.

    "Boris Nikolaevich" <borisnikolaevich.com> wrote in message
    news:#iNM$DEeDHA.1416TK2MSFTNGP12.phx.gbl...
    > IIRC, and I haven't checked this, the run method returns a number
    indicating
    > success (0) or error (any other value). Since the data type Long Integer
    is
    > obviously NOT an object, you're getting the error because you're trying to
    > "Set objWsRun = ... " instead of just letting "lngResult = ..."
    >
    > HTH, someone correct me if I'm wrong...
    >
    > --Boris
    >
    > "Mike" <mzehnerhotmail.com> wrote in message
    > news:upCTBd%23dDHA.2304TK2MSFTNGP11.phx.gbl...
    > > Hi -
    > >
    > > I am trying to get this piece of script to work without any success. I
    am
    > > running this on W2K w/SP4 and IIS 5.0. I am using Windows Integrated
    > > Authentication and logging on as a Domain Admin.
    > >
    > > ' Create File System Object
    > > Set objFiles = Server.CreateObject("Scripting.FileSystemObject")
    > >
    > > ' Check for duplicate folder name
    > > If objFiles.FolderExists(strHomeDirectory)
    > >
    > > Then WScript.Echo "A home folder " & strHomeDirectory & " already
    exists.
    > A
    > > new home folder will need to be created manually."
    > >
    > > Else
    > >
    > > 'Create the User HomeDirectory - This works!
    > > objFiles.CreateFolder(strHomeDirectory)
    > >
    > > ChangeFolderSettings("AUserFolder")
    > >
    > > Sub ChangeFolderSettings(strLoginID)
    > >
    > > Dim cmdCacls
    > > Dim objWsShell
    > > Dim objWsRun
    > >
    > > cmdCacls = "cmd /c echo y| CACLS.EXE \\" & strServer & "\" &
    > > strStudentGradYear & "\" & strInit & "\" & strLoginID & " /e /g " &
    > > strLoginID & ":C"
    > > Set objWsShell = Server.CreateObject("WScript.Shell")
    > > ' IIS does not like this
    > > Set objWsRun = objWsShell.run(cmdCacls, 0, True)
    > >
    > > Set objWsShell = nothing
    > > Set objWsRun = nothing
    > >
    > > End Sub
    > >
    > > End If
    > >
    > > At the Set objWsRun = objWsShell.run(cmdCacls, 0, True) line IIS
    returns
    > an
    > > error stating:
    > >
    > > Microsoft VBScript runtime (0x800A01A8)
    > > Object required: 'objWsShell.run(...)'
    > >
    > > The folder does get created sucessfully.
    > >
    > > Any help on this or other methods of setting folder permissions within
    an
    > > ASP page would be greatly appreciated.
    > >
    > > Thanks!!!
    > >
    > > Mike
    > >
    > >
    >
    >

    Mike Guest

  7. #7

    Default why doesn't this work?

    Hi,
    I can't seem to get this right. When I run my script nothing is put into the
    db-table. Can any of you see what is wrong?

    $conn = mysql_connect("host", "user", "pass")
    or die("Could not connect: " . mysql_error());
    echo"connected";

    $sql = "INSERT INTO kalender
    (oprettet_dato,job_dato,oprettet_af,sted,pris,adga ng,detaljer)

    VALUES('$oprettet_dato','$job_dato','$user','$sted ','$pris','$adgang','$deta
    ljer')";

    mysql_query($sql);
    mysql_close($conn);

    Best regards
    Ricki


    Ricki Susic Guest

  8. #8

    Default Re: why doesn't this work?


    On 16-Oct-2003, "Ricki Susic" <rickiNOSPAMjoin-in.dk> wrote:
    > I can't seem to get this right. When I run my script nothing is put into
    > the
    > db-table. Can any of you see what is wrong?
    >
    > $conn = mysql_connect("host", "user", "pass")
    > or die("Could not connect: " . mysql_error());
    > echo"connected";
    >
    > $sql = "INSERT INTO kalender
    > (oprettet_dato,job_dato,oprettet_af,sted,pris,adga ng,detaljer)
    >
    > VALUES('$oprettet_dato','$job_dato','$user','$sted ','$pris','$adgang','$deta
    > ljer')";
    >
    > mysql_query($sql);
    > mysql_close($conn);
    add an 'or die(mysql_error())' to your mysql_query and let mysql tell you
    what's wrong.

    --
    Tom Thackrey
    [url]www.creative-light.com[/url]
    tom (at) creative (dash) light (dot) com
    do NOT send email to [email]jamesbutlerwillglen.net[/email] (it's reserved for spammers)
    Tom Thackrey Guest

  9. #9

    Default Re: why doesn't this work?

    On Thu, 16 Oct 2003 23:17:13 +0200, "Ricki Susic" <rickiNOSPAMjoin-in.dk>
    wrote:
    >I can't seem to get this right. When I run my script nothing is put into the
    >db-table. Can any of you see what is wrong?
    >
    >$conn = mysql_connect("host", "user", "pass")
    > or die("Could not connect: " . mysql_error());
    > echo"connected";
    >
    >$sql = "INSERT INTO kalender
    >(oprettet_dato,job_dato,oprettet_af,sted,pris,adg ang,detaljer)
    >
    >VALUES('$oprettet_dato','$job_dato','$user','$ste d','$pris','$adgang','$deta
    >ljer')";
    Do any of the variables above have values? Echo out $sql. Does it match what
    you expected?
    >mysql_query($sql);
    Never ignore the return value of mysql_query (or any other MySQL function), as
    queries can fail, returning 'false'. The function mysql_error() will tell you
    why.

    For debugging, you can use something like:

    $result = mysql_query($query)
    or die("Query failed: $query<br />Error: ".mysql_error()."<br />");

    For a production system, you should never display raw error messages to the end
    user, and should use some sort of graceful error handling to inform the user
    that the function is currently unavailable.

    Add error checking and run it again.

    --
    Andy Hassall (andyandyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url])
    Space: disk usage ysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])
    Andy Hassall Guest

  10. #10

    Default Re: why doesn't this work?

    Hi,
    Somehow there was an error on the server hosting the database. I got it
    fixed.

    Thanks
    Ricki


    Ricki Susic Guest

  11. #11

    Default Why doesn't this work?

    Hi all,
    Why doesn't Flash respond on a ESC-keypress?
    I tried the code below, but nothing happens...

    objListener = new Object();
    objListener .onKeyDown = function () {
    if (Key.isDown(Key.ESCAPE)) {
    loadMovieNum("exit.swf",0);
    }
    };
    Key.addListener(objListener );


    Sjaakie Helderhorst Guest

  12. #12

    Default Why doesn't this work?

    I created the following testcode:

    <?
    class Test
    {
    var $name;

    function Test()
    { $name = ""; }

    function setName($name)
    { $this->name = $name; }

    function getName()
    { return $this->name;}
    }

    $item = new Test();

    $a = $item;
    $b = $item;

    $a->setName("Test");

    echo $a->getName(); // Displays "Test"
    echo $b->getName(); // Displays nothing, why??

    ?>

    I expect that both lines display "Test". But it doesn't. If think that's
    strange because $a and $b both point to the same object $item, so if I
    set the variable 'name' with $a I must be able to get the variable
    'name' with $b. But as the test proves, this doesn't work.
    Can someone explain what my thinking-error is and how to solve this
    problem?

    Jan Peter
    J.P. Guest

  13. #13

    Default Re: Why doesn't this work?

    J.P. wrote:
    > I expect that both lines display "Test". But it doesn't. If think
    > that's strange because $a and $b both point to the same object
    > $item, so if I set the variable 'name' with $a I must be able to get
    > the variable 'name' with $b. But as the test proves, this doesn't
    > work.
    > Can someone explain what my thinking-error is and how to solve this
    > problem?
    >
    In PHP 4, you will have to create references from the object instance:

    $a =& $item;
    $b =& $item;

    See: [url]http://nl2.php.net/references[/url] for more info.


    JW



    Janwillem Borleffs Guest

  14. #14

    Default Re: Why doesn't this work?

    Janwillem Borleffs wrote:
    > J.P. wrote:
    >
    >>I expect that both lines display "Test". But it doesn't. If think
    >> that's strange because $a and $b both point to the same object
    >>$item, so if I set the variable 'name' with $a I must be able to get
    >>the variable 'name' with $b. But as the test proves, this doesn't
    >>work.
    >>Can someone explain what my thinking-error is and how to solve this
    >>problem?
    >>
    >
    >
    > In PHP 4, you will have to create references from the object instance:
    >
    > $a =& $item;
    > $b =& $item;
    >
    > See: [url]http://nl2.php.net/references[/url] for more info.
    >
    Okay, thanks a lot. The code is working again. Up to the next problem.
    A good answer is also: "J.P.: forget pointers!" ;)

    --

    J.P.
    J.P. Guest

Similar Threads

  1. Doesn't work on the web
    By vistus in forum Coldfusion Flash Integration
    Replies: 1
    Last Post: July 1st, 08:43 AM
  2. Why doesn't this work??
    By kimber13 in forum Dreamweaver AppDev
    Replies: 0
    Last Post: February 23rd, 08:45 PM
  3. Why doesn't this work ?
    By Somnifer in forum Macromedia Director Basics
    Replies: 2
    Last Post: April 21st, 02:14 PM
  4. Help w/ SQL doesn't work
    By Rob in forum Microsoft SQL / MS SQL Server
    Replies: 3
    Last Post: July 4th, 12:36 AM
  5. why this doesn't work (tm)? :)
    By Matija Papec in forum PERL Miscellaneous
    Replies: 2
    Last Post: June 26th, 11:36 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139