Hi all!
Im uploading files to my server and i want to put the video files and image files in different locations, so i made script to check the files extension and set the upload dir accordingly.
The problem is that if i upload sample.avi it puts it in the image dir.
[code]<?php
session_start();
header(‘P3P: CP=“IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA”’);
$file_count = count ($FILES[“file”][“name”]);
for ($i=0; $i < $file_count; $i++) {
$fname = str_replace (" ", "", $_FILES[“file”][“name”][$i]);
$ftype = strrchr ($fname, ‘.’);
$fsize = $_FILES[“file”][“size”][$i];
$ftemp = $_FILES[“file”][“tmp_name”][$i];
echo $fname;
echo $ftype;
echo $fsize;
echo $ftemp;
if ($ftype = ".jpg" | $ftype = ".jpeg" | $ftype = ".png" | $ftype = ".gif") {
$uploadtarget = "/var/www/insite/resources/images/";
$uploadfile = $uploadtarget.$fname;
$redirect = "../home.php?body=image.php";
if (move_uploaded_file ($ftemp, $uploadfile)) {
echo "<div align='center'>Upload successful</div>";
}
else {
echo "<div align='center'>Upload failed</div>";
}
}
elseif ($ftype = ".avi" || $ftype = ".mkv") {
$uploadtarget = "/var/www/insite/resources/videos/";
$uploadfile = $uploadtarget.$fname;
$redirect = "../home.php?body=videos.php";
if (move_uploaded_file ($ftemp, $uploadfile)) {
echo "<div align='center'>Upload successful</div>";
}
else {
echo "<div align='center'>Upload failed</div>";
}
}
}
header (“refresh: 3; url=$redirect”);
?>[/code]
Strange this is that when uploading sample.avi the $ftype output is correctly .avi.
So what i going wrong here? Im out of ideas!