On Saturday 05 April 2003 00:41, Michael Arena wrote:
> After reading the file_upload section on PHP.net i got the following script
> working on the  server..it sends an attachment from a form now but it's
> just of size 0 and always a txt file. I know it must be some little thing
> wrong then this will work, maybe you can eye it for me and let me know if
> you think i should change anything..

Michael, I referred you to the upload example in the manual (which you say you 
got working) so that you will have a solid working foundation to build upon. 
In the example, the code to check whether a file has been uploaded is:

  if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {

So why are you using this:

>      if ($fileatt != "")
>      {





>     $uploaddir = '/home/sites/webserver.agraservices.net/web/mike/';
>     echo "it found the attachment";
>        move_uploaded_file($_FILES['fileatt']['tmp_name'], uploaddir .
> $_FILES['fileatt']['name']);
>    }

As has been pointed out you're missing the $ in uploaddir.

>  // Obtain file upload vars
>    $fileatt      = "/home/sites/webserver.agraservices.net/web/mike/";   //
> Location of file on server
>    $fileatt_type = $_FILES['fileatt']['type'];// Type of file being sent
>    $fileatt_name = $_FILES['fileatt']['name'];// Name of file
>
>  $headers = "From: $from";
>
>  if (file_exists($fileatt))
>     {
>    // Read the file to be attached ('rb' = read binary)
>    $file = fopen($fileatt,'rb');
>    $data = fread($file,filesize($fileatt));
>    fclose($file);

$fileatt is pointing to a directory. You need to define it as:

$fileatt = 
"/home/sites/webserver.agraservices.net/web/mike/{$_FILES['fileatt']['name']}";

Note the braces {}. Read the language reference of the manual (not sure where 
exactly it is so can't be more specific) to see why they're needed and how 
they work.

Not sure whether there are any more errors in your code, but correct the above 
first and see where that gets you.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Hailing frequencies open, Captain.
*/


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

Reply via email to