Link to home
Start Free TrialLog in
Avatar of mbigrad
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($sqlQuery);
$data = $sqlServer->getDataSetArray();

$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']['name'] != '')
 {
 @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;
 }
ASKER CERTIFIED SOLUTION
Avatar of matt_mcswain
matt_mcswain

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mbigrad
mbigrad

ASKER

Thanks for getting back to me. Unfortunately I already tried using "move_uploaded_file", the script still throws out an error. And yes, I have the form set up correctly.
Avatar of Roonaan
Possible traps would be:
1. Misspelled destination filename
2. Misspelled destination folder
3. No write-rights on folder.

Have you checked these all?

-r-
Avatar of mbigrad

ASKER

Yes, I have checked all these and they are set correctly
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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