upload form and php question
Posted: Tue Apr 01, 2008 1:13 pm
hello guys something is driving me crazy , i got Html file that contains simple file upload
and php file that should get the path of the file and read only some of the file , then run com file and store it on the server
but the program begins when i CANT extract path or anything from the html file
please hel me
upload.html:
encode.php
and php file that should get the path of the file and read only some of the file , then run com file and store it on the server
but the program begins when i CANT extract path or anything from the html file
please hel me
upload.html:
Code: Select all
<form action="encode.php" method="post" enctype="multipart/form-data">
<p>
<label for="file">Select a file:</label> <input type="file" name="userfile" id="file"> <br />
<button>Upload File</button>
<p>
</form>
Code: Select all
<?php
//this 4 lines returns nothing :(! and all i need is to have $path
echo "Upload: " . $_FILES["userfile"]["name"] . "<br />";
echo "Type: " . $_FILES["userfile"]["type"] . "<br />";
echo "Size: " . ($_FILES["userfile"]["size"] / 1024) . " Kb<br />";
echo "Stored in: " . $_FILES["userfile"]["tmp_name"];
switch (filetype($path)) {
case "dir":
echo "this function is not yet implemted";
break;
case "file":
{
$mp3File = fopen($path,"r");
$SampleSize=filesize($path) / 4;
fseek($mp3File, 1048576); //skip 1mb
$data = fread($mp3File, $SampleSize);
$SampleName="Sample_" .basename($path);
touch($SampleName);
chmod($SampleName,0666);
$mp3Sample = fopen($SampleName,"r+");
fwrite($mp3Sample,$data);
fclose($mp3Sample);
fclose($mp3File);
$runLame = "c:\\wamp\\www\\lame.exe --abr 64 -f c:\wamp\www\Sample_temp.mp3";
$WshShell = new COM("WScript.Shell");
$output = $WshShell->Exec($runLame)->StdOut->ReadAll;
if (strpbrk($output,"done")) {
echo $SampleName." Seccessfully Encoded" ;
} else {
echo "Faild";
}
}
break;
}
//$path="c:\\wamp\www\\temp.mp3";
?>