Hi everyone,
I have 2 php files that I use to upload a file into a folder. This 2 files are located inside of a subfolder with the following code:
The first one calls the file and the name is call.php:
<html>
<head>
<title>Upload script</title>
</head>
<body>
<b>Simple example of uploading a file</b><br />
Choose a file to be uploaded<br />
<form action="sample.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" size="50" />
<input type="submit" value="Upload" />
</form>
</body>
</html>
The second one save the file into the folder and the name is sample.php:
$targetfolder = "files/";
$targetfolder = $targetfolder . basename( $_FILES['file']['name']) ;
$ok=1;
$file_type=$_FILES['file']['type'];
if ($file_type=="application/pdf" || $file_type=="image/gif" || $file_type=="image/jpeg") {
if(move_uploaded_file($_FILES['file']['tmp_name'], $targetfolder))
{
echo "The file ". basename( $_FILES['file']['name']). " is uploaded";
}
else {
echo "Problem uploading file";
}
}
else {
echo "You may only upload PDFs, JPEGs or GIF files.<br>";
}
If I keep the php files inside of a subfolder nothing happens and the files are not uploaded, but if I move both files to the root, then works pretty well. Can anyone please help me and tell me how can I solve this issue that I have?
Thanks in advance!!