Image uploads to folder with php

i have an image uploading script with php it work will in localhost server but when I upload the website to my domain server it will upload the image but not in the spathfic folder I set it well set the folders path as part of the image name like

the path is


the image name will be like this

upload\novelimage\...image that uploaded

i didnt no if it is error in the script or the server but i didnt see any need for uploads permission on thier side so i guess that the problem was on the script here is the script

  //upload files
            $avatarname = $_FILES['NovelImage']['name'];
            $avatarsize = $_FILES['NovelImage']['size'];
            $avatartmp = $_FILES['NovelImage']['tmp_name'];
            $avatartype = $_FILES['NovelImage']['type'];

            $avatarAllowedextention = array("jpeg", "jpg", "png", "gif");

            //get avatar extention

            $avatarextention = strtolower(end(explode('.', $avatarname)));
              #get the varibles from the form 
              $Novelname = $_POST['Novelname'];
              $Describe = $_POST['Describe'];
              $category = $_POST['langOpt3'];
              // condtion ? true and false
                  //check username
                  $formerrors = array();
                  if (! empty($avatarname) && ! in_array($avatarextention, $avatarAllowedextention)) {
                    $formerrors[] = 'avatar extension is not allowed';
                if (empty($avatarname)) {
                    $formerrors[] = 'empty avatar is not allowed';
                if ($avatarsize > 4194304) {
                    $formerrors[] = 'avatar size is bigger than 4mb';
                foreach ($formerrors as $error) {
                    echo '<div class="alert alert-danger">' . $error . '</div>';
                if (empty($formerrors)) {
                    $avatar = rand(0, 1000000) . '_' . $avatarname;

                    move_uploaded_file($avatartmp, "upload\novelimage\\" . $avatar);

                  $check = checkitem("NovelName", "novel", $Novelname);

                  if ($check == 1) {
                      $theMsg = "<div class='alert alert-danger'>sorry this user name is exit</div>";

                      redirecthome($theMsg, 'back');
                        //insert userinfo into database whith this info
                        $stmt = $con->prepare("INSERT INTO novel(NovelName, NovelImage, description) 
                        VALUES(:znovel, :zNovelImage, :zdescription)");
                            'znovel' => $Novelname,
                            'zNovelImage' => $avatar,
                            'zdescription' => $Describe
                        $lastid = $con->LastInsertId();
                        $stmt = $con->prepare("INSERT INTO book_category(novelid, categoryID) 
                        VALUES(:znovelid, :zcategoryID)");
                        foreach ($category as $cat) {
                                'znovelid' => $lastid,
                               'zcategoryID' => $cat

                    $theMsg = "<div class='alert alert-success '>" . $stmt->rowCount(). 'Record Updated</div>'; 

                    redirecthome($theMsg, 'back', 100);

i really cant see any problem here please help

Read more here:

Content Attribution

This content was originally published by Bushra Zaher at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: