Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2002
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy php posting binary to mysql: script question...

    I have a php script that writes binary (image) files posted from a html form to a mysql database.

    if (!$prod_file) $prod_file = "..\images\warning.gif";
    $prod_file = addslashes(fread(fopen($prod_file, "r"), filesize($prod_file)));

    and writes a default file (warning.gif) when an image is not posted from the form page.

    This works locally on my 'localhost' setup running the latest versions of PHP and MYSQL on IIS5.1. But when I upload the database and scripts to my ISP, whose phpinfo() parameters are set identically to mine (although they are running IIS4 with slightly older versions of PHP and MYSQL , i get an error when it tries to find and write the default file. Otherwise files that are posted as $prod_file are recognised and written to the db.

    errors are as follows:

    Warning: fopen("none","r") - No such file or directory in xyz

    Warning: stat failed for none (errno=2 - No such file or directory) in xyz

    Warning: Supplied argument is not a valid File-Handle resource in xyz.

    The rest of the fields (varchar and so on) are written properly despite the error.

    Could anyone suggest a solution cos I am at my wit's end and have 3 question marks hanging over my gradually balding cranium. All help gratefully recieved may lower my blood pressure!


    Regds

    Russ.

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The main differences you'd spot between localhost and sitehost would be the path system - until I upgraded my localhost, defining file paths was an illogical minefield.

    Primarily (online) all relative paths will be in reference to the heirarchically top containing document [yeppy - that makes sense]

    Your scriptlet is simply telling you that the defined image is not where you reference it to be - so change the path...

    if (!$prod_file) $prod_file = "..\images\warning.gif";

    if (!$prod_file) $prod_file = "\root\usr\whatever\images\warning.gif";

    or just try changing the \ bits to / - at least the one-dir-up might be recognised then.
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #3
    New to the CF scene
    Join Date
    Sep 2002
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    result!

    if ($prod_file=="none") $prod_file = ("../images/warning.gif");

    seems to have fixed it. makes sense now, suppose $prod_file was submitted all along, yet originally, !$prod_file was checking for the existance of the string, whereas above, it is checking for the value within the string.

    Doh!

    Thanks anyhows, i did try all permutations on the paths, before I tried something random.


  •  

    Posting Permissions

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