Re: [Jason] Website Membership Plugin -- Uploading Image(s)
Hi all,
I’ve inherited another designer's work and I’m having a (huge) bit of difficulty implementing this last bit of code.
I need to upload an image that’s already being saved to a folder by the existing code into to an upload field in a CMSB database record.
There are 2 active files involved in this process, (purchase.php (the form) and ordernow.php (the processing file)). There’s also an error checking file that is not involved at this point
The purchase.php (file) contains the form that gets submitted, which already contains an image upload field.
After error checking and some price calculations, the data is passed to the ordernow.php file (attached) that uploads the image to directory called “photo” and attaches the image to an email message that gets sent along with all of the form’s other information.
I’ve been able to use the series of existing variables in the ordernow.php file (attached) to create and populate the text based fields in a CMS database record in a customer_uploads table.
The problem comes in when I try to get the existing image inserted into the CMS record also.
There will only ever be one image and once uploaded the client will never have to change or delete it.
Here's some of the existing code in ordernow.php that I have to work with:
$name_of_uploaded_file =basename($_FILES['photo']['name']);
//get the file extension of the file
$type_of_uploaded_file =substr($name_of_uploaded_file,strrpos($name_of_uploaded_file, '.') + 1);
//get the size of the file
$size_of_uploaded_file =$_FILES["photo"]["size"]/1024;//size in KBs
//copy the temp. uploaded file to attachdoc folder
$upload_folder='photo/';
$path_of_uploaded_file = $upload_folder . $name_of_uploaded_file;
//echo 'path_of_uploaded_file'.$path_of_uploaded_file;
$tmp_path = $_FILES["photo"]["tmp_name"];
if(is_uploaded_file($tmp_path))
{
copy($tmp_path,$path_of_uploaded_file);
if(!copy($tmp_path,$path_of_uploaded_file))
{
$errors .= '\n error while copying the uploaded file';
}
}
I thought it would be fairly straight forward but I’ve tried butchering and implementing the code above and I’m getting nowhere.
I could really use some help.
Thanks,
Jerry Kornbluth
The first CMS Builder reference book is now available on-line!
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php