Move Uploded file does not work, on Godaddy (but works on localhost)

My simple code is:

   <?php 
    if(isset($_REQUEST['submit']))
    {
        $t = time();
        if ($_FILES['image']['name']!="")
              { 
         $target1 = "bannerImage/".$t.$_FILES['image']['name'];
          if (move_uploaded_file($_FILES['image']['tmp_name'],$target1))
                {
                //Code is not reaching Here
                 }
               }
    }
?>

I don’t know why it doesn’t work in Godaddy Server, but it works fine on my localhost

+4
source share
3 answers

I fixed the problem by giving the file permission. It was 644 by default, I just set it to 777.

Now it looks great to me

+1
source
<?php

    if(isset($_REQUEST['submit']))
    {
        $t = time();
        if ($_FILES['image']['name']!="")
              { 
                 $path = '/folder_name';
                 $uid = uniqid();
                 $name = basename($_FILES['image']['name']);
                 $final_path = $path."_".$uid."_"$iname;
          if (move_uploaded_file($_FILES['image']['tmp_name'],$final_path))
                {
                //Code is not reaching Here
                 }
               }
    }
?>

I think this script will help you

0
source

Try to give

Write the permission of the application group> to [Folder] .

It can be set from:

Hosting Management → [Your Domain] → Virtual Directories → [Folder] → Permissions to Access Directories

0
source

Source: https://habr.com/ru/post/1539943/


All Articles