PHP Make Directory -


i not sure why code breaking

mkdir("upload/".$username.'/'.$title.'/', 0700);       move_uploaded_file($_files["file"]["tmp_name"],       "upload/".$username.'/'.$title.'/' . $_files["file"]["name"]);       echo "stored in: " ."upload/".$username.'/'.$title.'/' . $_files["file"]["name"];       $link = "upload/".$username.'/'.$title.'/' . $_files["file"]["name"]; 

here errors

warning: mkdir() [function.mkdir]: no such file or directory in /volumes/shared/digital/_websites/_test/qpm/submit.php on line 101

warning: move_uploaded_file(upload/test/test/hand over.docx) [function.move-uploaded-file]: failed open stream: no such file or directory in /volumes/shared/digital/_websites/_test/qpm/submit.php on line 103

warning: move_uploaded_file() [function.move-uploaded-file]: unable move '/applications/mamp/tmp/php/phpyvo5b5' 'upload/test/test/hand over.docx' in /volumes/shared/digital/_websites/_test/qpm/submit.php on line 103 stored in: upload/test/test/hand over.docx1 record added

i;m sure had working , have somehow broke it?

the echo stored in echos correct string not sure why mkdir failing, apologies if simple fix

there few things should know mkdir():

  1. by default, can create directory if parent directory exists; can create intermediate directories if pass true third parameter.

  2. without absolute path, it's hard directory created. can either use configuration file store or use combination of __file__, __dir__ , dirname() derive it.

i further advice never use value of $_files['file']['name'] directly create files on server; use tempnam(), optionally in combination sanitized version of original file name.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -