PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Im pretty new to php and i just dont get how to do this. This code im posting will run and it will show the process of uploading the file but once its done and i go to check if its in my upload directory. Theres nothing there. I even tried looking in my temp directory. Heres the code:
FORM.PHP
<?php
if(!eregi("modules.php", $_SERVER['PHP_SELF'])){
die("You can't access this file directly...");
}
if ($_POST['submit']){ //changed
//these should come before the email
$bandname=$_POST['bandname'];
$genra=$_POST['genra'];
$description=$_POST['description'];
$history=$_POST['history'];
$email=$_POST['email'];
$website=$_POST['website'];
$influences=$_POST['influences'];
//Email Variables (these work fine)
$recipient = "mikegotnaild@hotmail.com";
$subject = "Bands Showcase Submission";
$message = "Band Name: $bandname, Genra: $genra, Band Description: $description, Band History: $history, Email: $email, Website: $website, Influences: $influences";
$subject=$_POST['subject'];
mail($recipient,$subject,$message);
// upload action script.
$uploaddir = $_SERVER['DOCUMENT_ROOT'] . '/localmm/upload/'; //changed
$uploadfile = $uploaddir . $_FILES['ufile[]']['name'];
print "<pre>";
if (move_uploaded_file($_FILES['ufile[]']['tmp_name'], $uploadfile)) {
print "File is valid, and was successfully uploaded. ";
print "Here's some more debugging info:\n";
print_r($_FILES);
} else {
print "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES);
}
print "</pre>";
//commented out the following line because it would prevent you from seeing the debugging info
//header("Location: http://naild.com/localmm/modules.php?na ... &file=sent");
}
?>
Possible file upload attack! Here's some debugging info:
Array
(
[ufile] => Array
(
[name] => Array
(
[0] => phpnuke.gif
[1] => Ataris - Are We There Yet.mp3
[2] => The Ataris - Let It Go.mp3
)
Using $somearray[] as a read method (write method would be $foo[] = 'something') doesn't usually work, so $_FILES['ufile[]']['tmp_name'] will fail as you'de need to specify the $ufile index.
You probably want to foreach() over the $FILES['ufile'] array and move each one.
<input type="hidden" name="MAX_FILE_SIZE" value="500000" />
<br>Upload Image: <center><input name="imageupload" type="file" /> </center> Max image size is 500kb
<input type="hidden" name="MAX_FILE_SIZE" value="3500000" />
<br>Upload mp3: <center><input name="mp3upload1" type="file" /> </center>  Max mp3 size is 3.5 mb.
<input type="hidden" name="MAX_FILE_SIZE" value="3500000" />
<br>Upload mp3: <center><input name="mp3upload2" type="file" /> </center>  Max mp3 size is 3.5 mb.
<input type="hidden" name="MAX_FILE_SIZE" value="7000000" />
<br>If Mp3 exceeds 3.5 mb Upload Here: <center><input name="mp3upload3" type="file" /> </center>
<center><i>If one of your mp3's exceeds 3.5 mb. You may only upload 1 mp3. But if they are 3.5mb or less you may upload 2. PLEASE ABIDE TO THIS RULE! If you do not. Your information will be discarded.</center></i>
<br><input type="submit" name="submit" value="Submit">
// upload action script.
$uploaddir = $_SERVERї'DOCUMENT_ROOT'] . '/localmm/upload/'; //changed
$uploadfile1 = $uploaddir . $_FILESї'imageupload']ї'name'];
$uploadfile2 = $uploaddir . $_FILESї'mp3upload1']ї'name'];
$uploadfile3 = $uploaddir . $_FILESї'mp3upload2']ї'name'];
$uploadfile4 = $uploaddir . $_FILESї'mp3upload3']ї'name'];
if (!move_uploaded_file($_FILESї'imageupload']ї'tmp_name'], $uploadfile1)) {
print "ERROR: File is invalid";
print_r($_FILES);
}
if (!move_uploaded_file($_FILESї'mp3upload1']ї'tmp_name'], $uploadfile2)) {
print "ERROR: File is invalid";
print_r($_FILES);
}
if (!move_uploaded_file($_FILESї'mp3upload2']ї'tmp_name'], $uploadfile3)) {
print "ERROR: File is invalid";
print_r($_FILES);
}
if (!move_uploaded_file($_FILESї'mp3upload3']ї'tmp_name'], $uploadfile4)) {
print "ERROR: File is invalid";
print_r($_FILES);
}
//commented out the following line because it would prevent you from seeing the debugging info
//header("Location: http://naild.com/localmm/modules.php?name=Bands_Showcase&file=sent");
}