php - Warning: move_uploaded_file() failed to open stream -
i trying upload file on ftp.
here code
$jname= "accounts of biotechnology research"; if (!is_dir('/trade/upload/ '.$jname)) { mkdir('/trade/upload/ '.$jname); // line 63 } move_uploaded_file($_files["submission_file"]["tmp_name"], "/trade/upload/$jname/" . $dup_name ); // line 67
trade folder inside public_html folder.
when uploading file gives me warning like,
warning: mkdir() [function.mkdir]: no such file or directory in /home/my_username/public_html/trade/upload.php on line 63 warning: move_uploaded_file(/trade/upload/accounts of biotechnology research/76164762-sm.pdf) [function.move-uploaded-file]: failed open stream: no such file or directory in /home/my_username/public_html/trade/upload.php on line 67 warning: move_uploaded_file() [function.move-uploaded-file]: unable move '/tmp/phphzxp0o' '/trade/upload/accounts of biotechnology research/76164762-sm.pdf' in /home/my_username/public_html/trade/upload.php on line 67
first: have space here mkdir('/trade/upload/ '.$jname);
. suppose should have mkdir('/trade/upload/'.$jname);
(same is_dir)
second: ensure can write trade/upload
directory.
third (and suppose real problem):
it looks trying upload directory full path: /home/my_username/public_html/trade/upload/
, code try create directory full path: /trade/upload/
. need change
if (!is_dir('/trade/upload/ '.$jname)) { mkdir('/trade/upload/ '.$jname); // line 63 }
to
if (!is_dir('upload/'.$jname)) { mkdir('upload/'.$jname); // line 63 (or maybe there should trade/upload, suppose current working dir /home/my_username/public_html/trade, upload/) }
another option force mkdir
create directories recursively:
mkdir('/trade/upload/'.$jname, 0755, true);
but in case, files uploaded /trade/upload/...
instead of /home/my_username/public_html/trade/upload/...
Comments
Post a Comment