mbigrad
asked on
Uploading images using PHP
Hello,
The code at the bottom has been giving me a lot of trouble. All it does is upload the name of the image file into the database. I need it to upload the image file itself. Please help!
Thanks,
mbigrad
$sqlQuery = "SELECT * FROM motorcycles WHERE id = '$this->_id'";
$sqlServer->execQuery($sql Query);
$data = $sqlServer->getDataSetArra y();
$this->_product_image_1 = $data["image_name_1"];
$this->_product_image_2 = $data["image_name_2"];
$this->_product_image_3 = $data["image_name_3"];
$this->_product_image_4 = $data["image_name_4"];
$this->_product_thumbnail = $data["thumbnail"];
$this->_product_image_dir = "http://www.mywebsite.com/images" . "/";
$filedir = $GLOBALS["base_imagedir"];
$file_name = "thumb_" . $_FILES['new_thumb']['name '];
if($_FILES['new_thumb']['n ame'] != '')
{
@unlink($filedir . $file_name);
$copy = copy($_FILES['new_thumb'][ 'tmp_name' ],$filedir . $file_name);
if($copy){
echo "$file_name | uploaded successfuly!<br>";
$real_path = realpath($uploads);
echo $real_path;
}else{
echo "$file_name | could not be uploaded!<br>";
}
$this->_product_thumbnail = $file_name;
}
The code at the bottom has been giving me a lot of trouble. All it does is upload the name of the image file into the database. I need it to upload the image file itself. Please help!
Thanks,
mbigrad
$sqlQuery = "SELECT * FROM motorcycles WHERE id = '$this->_id'";
$sqlServer->execQuery($sql
$data = $sqlServer->getDataSetArra
$this->_product_image_1 = $data["image_name_1"];
$this->_product_image_2 = $data["image_name_2"];
$this->_product_image_3 = $data["image_name_3"];
$this->_product_image_4 = $data["image_name_4"];
$this->_product_thumbnail = $data["thumbnail"];
$this->_product_image_dir = "http://www.mywebsite.com/images" . "/";
$filedir = $GLOBALS["base_imagedir"];
$file_name = "thumb_" . $_FILES['new_thumb']['name
if($_FILES['new_thumb']['n
{
@unlink($filedir . $file_name);
$copy = copy($_FILES['new_thumb'][
if($copy){
echo "$file_name | uploaded successfuly!<br>";
$real_path = realpath($uploads);
echo $real_path;
}else{
echo "$file_name | could not be uploaded!<br>";
}
$this->_product_thumbnail = $file_name;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Possible traps would be:
1. Misspelled destination filename
2. Misspelled destination folder
3. No write-rights on folder.
Have you checked these all?
-r-
1. Misspelled destination filename
2. Misspelled destination folder
3. No write-rights on folder.
Have you checked these all?
-r-
ASKER
Yes, I have checked all these and they are set correctly
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No comment has been added to this question in more than 21 days,so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:
[Points Split {matt_mcswain},{Roonaan} and {gruntar}]
Any objections should be posted here in the next 4 days. After that time, the question will be closed.
Kshitij Ahuja
EE Cleanup Volunteer
I will leave the following recommendation for this question in the Cleanup topic area:
[Points Split {matt_mcswain},{Roonaan} and {gruntar}]
Any objections should be posted here in the next 4 days. After that time, the question will be closed.
Kshitij Ahuja
EE Cleanup Volunteer
ASKER