Jump to content

Point images to upload to different directory


Mr.Canuck

Recommended Posts

I currently have a file upload form that uploads images to a folder on my server called "attachments". This is the directory path: www.mysite.com/docs/attachments/

However, I want the images to upload to www.mysite.com/data/attachments/ instead. I have included the relevant part of the PHP below. I have tried changing this: $cur_dir = $cur_dir."/".$dir; to this: $cur_dir = $cur_dir."www.mysite.com/data/attachments/".$dir;

and changing this: $dirs = explode("/","attachments//"); to this: $dirs = explode("www.mysite.com/data/","attachments//");

and also changing this: $_values[$file[0]."_real-name"] = "attachments/".date("YmdHis")."_".$_FILES[$file[0]]["name"]."_secure"; to this: $_values[$file[0]."_real-name"] = "www.mysite.com/data/attachments/".date("YmdHis")."_".$_FILES[$file[0]]["name"]."_secure"; But nothing has worked so far. Any suggestions would be appreciated.

 

foreach($files[$form] as $file){
         $str = $file[1];
         if (eval("if($str){return true;}")) {
            $_values[$file[0]] = $_FILES[$file[0]]["name"];
            $dirs = explode("/","attachments//");
            $cur_dir =".";
            foreach($dirs as $dir){
            $cur_dir = $cur_dir."/".$dir;
            if (!@opendir($cur_dir)) { mkdir($cur_dir, 0777);}}
            $_values[$file[0]."_real-name"] = "attachments/".date("YmdHis")."_".$_FILES[$file[0]]["name"]."_secure";
            copy($_FILES[$file[0]]["tmp_name"],$_values[$file[0]."_real-name"]);
            @unlink($_FILES[$file[0]]["tmp_name"]);
         }else{
          $flag=true;
          if ($_isdisplay) {
              //$ExtFltr = $file[2];
              //$FileSize = $file[4];
            if (!eval("if($file[2]){return true;}")){echo $file[3];}
            if (!eval("if($file[4]){return true;}")){echo $file[5];}
              $_ErrorList[] = $file[0];
          }
         }
      }

Link to comment
Share on other sites

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.