Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.