Volledige versie bekijken : php variabel problem
gibson18
%Europe/Berlin %891 %2005, 22:23
Hoe werk ik met deze variabele. De map uploads ligt vast maar die $dir kan varieren aan de hand wat ik in T1 ingeef. Ma de syntax is ni juist denk ik.
<?php
$dir=$_POST['T1'];
print($dir);
// Where the file is going to be placed
$target_path = "uploads/['$dir']/";
Roenes
%Europe/Berlin %898 %2005, 22:33
$target_path = "uploads/$dir/";Werkt dit niet? :)
Maar het is allemaal een beetje vaag. Kun je iets meer uitleggen of iets meer code geven? :)
gibson18
%Europe/Berlin %501 %2005, 13:02
Nee dit werkt niet. Wel de directory waar de file opgeslagen moet worden kan varieren. Dit wordt ingegevens in een inputbox van een form. die print dir is een test en hij geeft de juiste map weer. Maar hij blijft het bestand nog altijd gewoon in de map uploads/ zetten en ni in de submap multimedia
<?php
$dir=$_POST['T1'];
print($dir);
// Where the file is going to be placed
$target_path = "uploads/'$dir'/";
// Add the original filename to our target path. Result is "uploads/filename.extension"
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$_FILES['uploadedfile']['tmp_name']; // This is how we will get the temporary file...
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>
gibson18
%Europe/Berlin %635 %2005, 16:14
Niemand een oplossing?
latino
%Europe/Berlin %829 %2005, 20:54
dit
$target_path = "uploads/'$dir'/";
moet volgens mij
$target_path = "uploads/".$dir."/";
dit worden
kevinrommen
%Europe/Berlin %837 %2005, 21:05
<?php
$dir=$_POST['T1'];
print($dir);
// Where the file is going to be placed
$target_path = "uploads/" . $dir . "/";
// Add the original filename to our target path. Result is "uploads/filename.extension"
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$_FILES['uploadedfile']['tmp_name']; // This is how we will get the temporary file...
$target_path = "uploads/";
$target_path .= basename($_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
?>
dit zou hij moeten zijn denk ik
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.