mkdir() en move_uploaded_file() (Opgelost)
webbiexl - 15/04/2009 21:55
|
PHP interesse |
|
Ik heb gekeken op php.net en hier op het forum maar kan de oplossing op mijn probleem niet vinden...
de bedoeling van dit stuk hieronder is dat ie de bestanden hernoemd en verplaatst...
$split = str_split(strtolower($_SESSION['username']), 1);
$_POST['large'] = $_SESSION['large'];
$_POST['thumb'] = $_SESSION['thumb'];
$_POST['large'] = str_replace($_SESSION['random_key'], $_POST['projectnaam'], $_POST['large']);
$_POST['thumb'] = str_replace($_SESSION['random_key'], $_POST['projectnaam'], $_POST['thumb']);
$_POST['large'] = str_replace("temp/", "", $_POST['large']);
$_POST['thumb'] = str_replace("temp/", "", $_POST['thumb']);
$_POST['large'] = str_replace("resize", $_SESSION['username'], $_POST['large']);
$_POST['thumb'] = str_replace("_", "_".$_SESSION['username']."_", $_POST['thumb']);
$image = "/uploads/".$split['0']."/".$split['1']."/".strtolower($_SESSION['username'])."/image";
$thumb = "/uploads/".$split['0']."/".$split['1']."/".strtolower($_SESSION['username'])."/thumb";
if(!is_dir($image)){
mkdir($image, 0777);
chmod($image, 0777);
}
if(!is_dir($thumb)){
mkdir($thumb, 0777);
chmod($thumb, 0777);
}
$image = $image."/".$_POST['large'];
$thumb = $thumb."/".$_POST['thumb'];
move_uploaded_file($_SESSION['large'], $image);
move_uploaded_file($_SESSION['thumb'], $image);
$split = str_split (strtolower($_SESSION['username']), 1); $_POST['large'] = $_SESSION['large']; $_POST['thumb'] = $_SESSION['thumb']; $_POST['large'] = str_replace($_SESSION['random_key'], $_POST['projectnaam'], $_POST['large']); $_POST['thumb'] = str_replace($_SESSION['random_key'], $_POST['projectnaam'], $_POST['thumb']); $_POST['large'] = str_replace("temp/", "", $_POST['large']); $_POST['thumb'] = str_replace("temp/", "", $_POST['thumb']); $_POST['large'] = str_replace("resize", $_SESSION['username'], $_POST['large']); $_POST['thumb'] = str_replace("_", "_".$_SESSION['username']."_", $_POST['thumb']); $image = "/uploads/".$split['0']."/".$split['1']."/".strtolower($_SESSION['username'])."/image"; $thumb = "/uploads/".$split['0']."/".$split['1']."/".strtolower($_SESSION['username'])."/thumb"; } } $image = $image."/".$_POST['large']; $thumb = $thumb."/".$_POST['thumb'];
maar hier gebeurd vrij weinig... hij maakt de mappen niet aan laat staat dat hij ze verplaatst
kan iemand mij hiermee helpen?
|
2 antwoorden
Gesponsorde links |
|
webbiexl - 15/04/2009 22:13 (laatste wijziging 15/04/2009 22:58)
|
PHP interesse |
|
staat aan
De oplossing:
$split = str_split(strtolower($_SESSION['username']), 1);
$_POST['large'] = $_SESSION['large'];
$_POST['thumb'] = $_SESSION['thumb'];
$_POST['large'] = str_replace($_SESSION['random_key'], $_POST['projectnaam'], $_POST['large']);
$_POST['thumb'] = str_replace($_SESSION['random_key'], $_POST['projectnaam'], $_POST['thumb']);
$_POST['large'] = str_replace("temp/", "", $_POST['large']);
$_POST['thumb'] = str_replace("temp/", "", $_POST['thumb']);
$_POST['large'] = str_replace("resize", $_SESSION['username'], $_POST['large']);
$_POST['thumb'] = str_replace("_", "_".$_SESSION['username']."_", $_POST['thumb']);
$image = "uploads/".$split['0']."/".$split['1']."/".strtolower($_SESSION['username'])."/image/";
$thumb = "uploads/".$split['0']."/".$split['1']."/".strtolower($_SESSION['username'])."/thumb/";
if(!is_dir($image)){
mkdir($image, 0777, true);
chmod($image, 0777);
}
if(!is_dir($thumb)){
mkdir($thumb, 0777, true);
chmod($thumb, 0777);
}
$image = $image.$_POST['large'];
$thumb = $thumb.$_POST['thumb'];
rename($_SESSION['large'], $image);
rename($_SESSION['thumb'], $image);
$split = str_split (strtolower($_SESSION['username']), 1); $_POST['large'] = $_SESSION['large']; $_POST['thumb'] = $_SESSION['thumb']; $_POST['large'] = str_replace($_SESSION['random_key'], $_POST['projectnaam'], $_POST['large']); $_POST['thumb'] = str_replace($_SESSION['random_key'], $_POST['projectnaam'], $_POST['thumb']); $_POST['large'] = str_replace("temp/", "", $_POST['large']); $_POST['thumb'] = str_replace("temp/", "", $_POST['thumb']); $_POST['large'] = str_replace("resize", $_SESSION['username'], $_POST['large']); $_POST['thumb'] = str_replace("_", "_".$_SESSION['username']."_", $_POST['thumb']); $image = "uploads/".$split['0']."/".$split['1']."/".strtolower($_SESSION['username'])."/image/"; $thumb = "uploads/".$split['0']."/".$split['1']."/".strtolower($_SESSION['username'])."/thumb/"; mkdir($image, 0777, true); } mkdir($thumb, 0777, true); } $image = $image.$_POST['large']; $thumb = $thumb.$_POST['thumb']; rename($_SESSION['large'], $image); rename($_SESSION['thumb'], $image);
als je mkdir(); gebruikt:
mkdir("/map/", "0777", true); // fout
mkdir("map/", "0777", true); // correct!
mkdir("/map/", "0777", true); // fout mkdir("map/", "0777", true); // correct!
move_uploaded_file() kan geen al geuploade bestanden verhuizen daar voor moet men rename() gebruiken
met dank aan Marten, Threetimes en Mediaval |
Gesponsorde links |
|
Dit onderwerp is gesloten. |
|