|
-
May 2nd, 2003, 05:27 AM
#1
Thread Starter
Member
Upload Problem
Hi all,
I'm using the following code to upload an image .....it works fine locally...But on the remote server it doesn't upload the image..
-------------------------------------------------------------------------------
//form field name is "images"
$image = "$images_name";
$exten = explode(".", $image);
$exten = strtolower($exten[1]);
$exten = chop($exten);
if (($exten == "gif") || ($exten == "jpg") || ($exten == "jpeg"))
{
$path = "whats_new/$image";
move_uploaded_file($images, "$path");
$sql = "INSERT INTO item (itm_name, description, unit_price, stock, image) VALUES ('$itm_name', '$description', '$unit_price', '$stock', '$image')";
$res = mysql_query($sql);
header("location:add_itm.php?msg=add");
}
else
{
echo "Wrong extension";
}
-----------------------------------------------------------------------------
Kindly check whats wrong..
Thanks
FmKing
***************************
Sharing Knowledge = Good Deed
***************************
-
May 3rd, 2003, 08:49 PM
#2
Stuck in the 80s
It would help to know what, if any, error your receive. If you don't receive an error, can you explain what happens?
-
May 5th, 2003, 01:33 AM
#3
Thread Starter
Member
Thank you for replying,
When i submit....The name of the file goes to the database but not the image on the remote server.....
It seems to me that there is something wrong in the path.
What exactly should the path be....i'm using
$path = "whats_new/$image";
Thanks
FmKing
***************************
Sharing Knowledge = Good Deed
***************************
-
May 5th, 2003, 09:16 AM
#4
Stuck in the 80s
Try using the absolute path to your folder:
Code:
$path = "/home/your_site/public_html/whats_new/$image";
-
May 5th, 2003, 09:21 AM
#5
Stuck in the 80s
You also might want to try this:
Code:
$res = move_uploaded_file($images, "$path");
if ($res === false) {
die("Invalid upload file!");
}
That way you can make sure the upload file is valid. Also, where are you getting $images from?
Is that a global form variable? If so, that's a big no-no.
Try using:
Code:
$res = move_uploaded_file($_FILES['images']['name'], "$path");
if ($res === false) {
die("Invalid upload file!");
}
Assuming $images was a form variable.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|