From: "Daniel Perez Clavero" <[EMAIL PROTECTED]>

> Warning: fread(): supplied argument is not a valid stream resource in
> c:\program files\apache group\apache\htdocs\dpc\modulos\mod_ins_doc.php on
> line 13
>
> I´ve got a form that calls a module to insert data. IT WAS WORKING before
I
> switched the Register Globals to Off value. I made the proper chages to
> recieve variables, but i cannot make it work. Here is the code of the
insert
> module.

Since register_globals is OFF, you need to use $_FILES. The uploaded data is
present in $_FILES, not $_POST.

http://us2.php.net/manual/en/features.file-upload.php

> <?
> $dbhost="localhost";
> $dbusuario="user";
> $dbpassword="password";
> $db="database";
> $conexion = mysql_connect($dbhost,$dbusuario,$dbpassword);
> mysql_select_db($db,$conexion);
>
> $farchivo=$_POST['farchivo'];

$farchivo = $_FILES['farchivo']['tmp_name'];

for example...

> $binary = addslashes (fread(fopen($farchivo, "rb"), filesize($farchivo)));
>
> $nombre=$_POST['fnombre'];
> $descripcion=$_POST['fdescripcion'];
> $insert_data = "INSERT INTO
> documentos (id, nombre, descripcion, fichero, nomfichero, tamfichero,
> tipofichero)
> VALUES ('', '$nombre','$descripcion','$binary', '$farchivo_name',
> '$farchivo_size', '$farchivo_type')";
> mysql_query($insert_data,$conexion) or die("Couldn't insert data.");
> header("Location: ../index.php?sec=doc0");
> ?>
>
> The code of the form is correct. This is the name of the input fields.
>
> <INPUT TYPE=\"text\" NAME=\"fnombre\" SIZE=\"20\"
> CLASS=\"identificationfield\">";
> <TEXTAREA name=\"fdescripcion\" cols=\"40\" rows=\"3\"
> CLASS=\"identificationfield\"></textarea>";
> <INPUT type=\"file\" name=\"farchivo\" size=\"30\"
> CLASS=\"identificationfield\">";

---John Holmes...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to