Question

Ok I am new to mysql and php array system. I need this to work with my simple file script I have made. Below is the code like I said it works find. But I can not figure out how to add the extra inputs...

if(isset($_FILES["file"])) {
if ($_FILES["file"]["error"] > 0) {
// Error
$up = 0;
} else {
$name = $_FILES["file"]["name"];
move_uploaded_file($_FILES["file"]["tmp_name"], UPLOADS."/$name");
$up = 1;
}
header('Location: upload.php?upload='.$up);
}
if(!$steam->isLoggedin()) {
echo "Sorry Guest, You need to login with steam to upload! <br /> \n \n";
} else {
// Check our return status to see if it worked or not
if(isset($_GET['upload'])) {
if($_GET['upload'] == 1) {
echo 'Uploaded succesfully';
} else {
echo 'Upload failed';
}
}
}
<form action="upload.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<h1>Upload A ScreenShot</h1>
<em>Photo Name:</em><input name="name" type="text" id="name" />
<br />
<em>Size:</em><input name="size" type="text" id="size" />
<br />  
<em>Category</em>
<select id="category" name="category">
<option>ScreenShots</option>
</select>
<br />
<em>Upload</em>:<input type="file" name="file" />
<br />
<input type="submit" name="Submit" value="Submit" />
</form>

The upload part works. But what I can not do is figure out how to add Size, Description and Category to the php code. I just do not know how to set that part up and I do not know were to place the code. If anyone could help me I would really apricate it :).

Was it helpful?

Solution

$name = isset($_POST['name']); just returns true what you want to do with this line:

$filename = $name."_"."$type"."_".$rand."_".$_FILES['file']['name'];

and don't forget about enctype= multipart/form-data in html whithout it you could not save your file

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top