My names Nic and I am a very new to php coding, so I just started coding today.
So far, I have 3 files, and all work perfectly, but it needs tweaking!
I tweaked the last part to display the link to the file and a hr after to show that it finished the upload of that file.
Here is what I have so far.
There is the style and stuff but you only need the important stuff.
http://files.gamer-grid.com
index.php
- Code: Select all
<form name="form1" method="post" action="uploadForm2.php">
<p>Enter the amount of uploads you will need below. Max = 5.</p>
<p>
<select name="uploadNeed" id="uploadNeed">
<option value="1">1 Upload</option>
<option value="2">2 Uploads</option>
<option value="3">3 Uploads</option>
<option value="4">4 Uploads</option>
<option value="5">5 Uploads</option></select>
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
uploadform2.php
- Code: Select all
<form name="form1" enctype="multipart/form-data" method="post" action="processFiles.php">
<p>
<?
// start of dynamic form
$uploadNeed = $_POST['uploadNeed'];
for($x=0;$x<$uploadNeed;$x++){
?>
<input name="uploadFile<? echo $x;?>" type="file" id="uploadFile<? echo $x;?>">
</p>
<?
// end of for loop
}
?>
<p><input name="uploadNeed" type="hidden" value="<? echo $uploadNeed;?>">
<input type="submit" name="Submit" value="Submit">
</p>
</form>
processfiles.php
- Code: Select all
<?php
$uploadNeed = $_POST['uploadNeed'];
// start for loop
for($x=0;$x<$uploadNeed;$x++){
$file_name = $_FILES['uploadFile'. $x]['name'];
// strip file_name of slashes
$file_name = stripslashes($file_name);
$file_name = str_replace("'","",$file_name);
$copy = copy($_FILES['uploadFile'. $x]['tmp_name'],$file_name);
// check if successfully copied
if($copy){
echo "$file_name | uploaded sucessfully!<br>";
echo "Use this link to download it and send it to others!<br>";
echo "<a href='http://files.gamer-grid.com/$file_name'>http://files.gamer-grid.com/$file_name</a><br><br><hr>";
}else{
echo "$file_name | could not be uploaded!<br>";
}
} // end of loop
?>
Now I want it at the very end to say like "3/4 uploads sucessfull". where yea.
im thinking for the processfiles:
- Code: Select all
<?php
$uploadNeed = $_POST['uploadNeed'];
// start for loop
for($x=0;$x<$uploadNeed;$x++){
$file_name = $_FILES['uploadFile'. $x]['name'];
// strip file_name of slashes
$file_name = stripslashes($file_name);
$file_name = str_replace("'","",$file_name);
$copy = copy($_FILES['uploadFile'. $x]['tmp_name'],$file_name);
// check if successfully copied
if($copy){
echo "$file_name | uploaded sucessfully!<br>";
echo "Use this link to download it and send it to others!<br>";
echo "<a href='http://files.gamer-grid.com/$file_name'>http://files.gamer-grid.com/$file_name</a><br><br><hr>";
$successful + 1 == $succesfull
}else{
echo "$file_name | could not be uploaded!<br>";
}
} // end of loop
?>
<center><php echo $successful ?>/<php echo $boxes ?></center>
Something like that.
Is it like BASIC programming, like I created programs for my calculator, but php looks somewhat similar so i think ill learn quickly.
Thanks.


