Jump to content

[SOLVED] File upload problem


ali_kiyani

Recommended Posts

Hello

 

I developed a site for one of my client. The site was working fine on one host but when he moved to another host, file upload feature stopped working. I am using simple file upload code as below:

 

if(isset($_FILES['image']))
{
     $target_path = "../images/products/";

     $target_path = $target_path . basename($_FILES['image']['name']);
        
     $upload_result = move_uploaded_file($_FILES['image']['tmp_name'], $target_path);
}

 

I have double checked that the directory I am uploading to is writeable.

 

When I contacted the host they say that I need to set following TMP dir for uploads to work

 

/home/www/mysite.com/tmp/

 

How do I make changes to my code!? I mean how can I set this dir in my code!? Or do I need to do something else?!

 

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/42322-solved-file-upload-problem/
Share on other sites

Problem is solved. I didn't change anything in my code and it is working. May be host made some changes.

But strange thing is....the code I am using above is for product images....and dir permissions are set to 755 and it is uploading!!

But the same code is not working for category images (another directory).....I had to set dir permissions to 757 to make it work.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.