php - script upload file doesn't upload into uuid folder -



php - script upload file doesn't upload into uuid folder -

i'm creating in localhost (files not published in remote server), web app add together features need. 1 of them upload wav file, want upload different folder each upload. used code works normal folder. edited in add together options need (remove blank space in file name etc.), when set "$folderuuid" "move_upload_file", folder created, file isn't uploaded into.

another feature won't able understand add together create uuid folder when file uploaded, not every time page refreshed. read give-and-take php file upload creating directory , understand have utilize $_session, code doesn't work.

here php code:

if(isset($_post['submit'])) { $allowedexts = array("wav"); $filename = $_files['file']['name']; $extension = substr($filename, strrpos($filename, '.') + 1); if(!is_dir("inputfiles/". $_session["folder"] ."/")) { mkdir(uniqid('inputfiles/'), 0700). $_session["folder"] ."/" ; } if(in_array($extension, $allowedexts)) { if ($_files["file"]["error"] > 0) { echo "return code: " . $_files["file"]["error"] . "<br />"; } else { echo "name: " . $_files["file"]["name"] . "<br />"; echo "file kind: " . $_files["file"]["type"] . "<br />"; echo "size: " . ($_files["file"]["size"] / 1024) . " kb<br />"; if (file_exists("inputfiles/" . $_files["file"]["name"])) { echo $_files["file"]["name"] . " file già esistente. "; } else { move_uploaded_file($_files["file"]["tmp_name"], $folderuuid . str_replace(" ", "",$_files["file"]["name"])); print "<br />"; echo "saved in: " . "inputfiles/" . $_files["file"]["name"]; print "<br />"; } } } else { echo "invalid file"; } }

here html code:

<form method="post" enctype="multipart/form-data" > <label for="file"><span>filename:</span></label> <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submit" value="submit" />

hope can help me prepare problems. kind regards brus

try code

if(isset($_post['submit'])) { $file_name = $_files['file']['name']; $tmp_file = $_files['file']['tmp_name']; //create directory file $temp = explode('.', $file_name); $dir = $temp[0]; $extension = strtolower($temp[1]); $allowedexts = array("wav"); if(!is_dir('inputfiles/'.$dir)){ mkdir("inputfiles/$dir",0700); } if(in_array($extension, $allowedexts)) { if ($_files["file"]["error"] > 0) { echo "return code: " . $_files["file"]["error"] . "<br />"; } else { echo "name: " . $_files["file"]["name"] . "<br />"; echo "file kind: " . $_files["file"]["type"] . "<br />"; echo "size: " . ($_files["file"]["size"] / 1024) . " kb<br />"; if (file_exists("inputfiles/" . $_files["file"]["name"])) { echo $_files["file"]["name"] . " file già esistente. "; } else { move_uploaded_file($tmp_file, "inputfiles/".$dir."/".$file_name); print "<br />"; echo "saved in: " . "inputfiles/$dir/" . $_files["file"]["name"]; print "<br />"; } } } else { echo "invalid file"; } }

php file-upload uuid

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -