Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Attaching a File to a Form Re: Attaching a File to a Form

#69341
lyleyboy
Member

Hi, Here to post my code as requested.

The form looks like this. Nothing special I’m sure you’ll agree.

Code:

Click browse to find the image you wish to upload.
The file size cannot exceed 1 MB

The processing PHP bit looks like this

Code:
1000000) {
echo “File size is bigger than 1 MB. It must be rezised in order to upload.”;
exit;
}
@copy(“$img2”, “/THIS IS MY SERVER PATH/$img2_name” )
or die(“Upload Failed!
Back“);
} else {
die(“No input file!.
Back“);
}

echo “Image Uploded”;
?>

Where I have "THIS IS MY SERVER PATH" you need to add in the actual path to your upload folder on your server. I’m sure you already know this but here we are in any case.
I have found the best way to find it is to force a PHP error say by removing a ; and the running the script. The path is output on the error page.

Incidentally I have just tested this and it worked fine for a .doc file. Uploaded it then I FTP’d it back to my machine and opened it without a problem.

If this doesn’t work then you may have to start looking at your server setup. I’m not expert with the setup but that may be where the problem lies.