Hi again php users!

Look at this code:

if (empty($form_data)) {$form_data = "none.png"}

$d = addslashes(fread(fopen($form_data, "rb"), filesize($form_data)));

I use it to put an image to the database.

It works fine on Windows, but on linux it says:

Warning: fopen("none","rb") - No such file or directory in /home/delcio/hosting/controle.php on line 125

Warning: Supplied argument is not a valid File-Handle resource in /home/delcio/hosting/controle.php on line 125

Is there any other better way to do this and solve that tricky problem?

    do you retrieve the $form_data from a file upload script? in case you do so, the default value for an empty field is "none" if im not mistaken...

    thus change it to

    if ($form_data != "none") ...

    even better it would work to check for the uploaded file name (i use that usually):

    if (!$form_data_name) ...

    i hope i got this right and could help...

    sid

      The 'rb' parameters are ONLY allowed on Windows.
      You have to use something else on *NIX.

        Write a Reply...