Staredit Network

Staredit Network -> Computers and Technical -> PHP help
Report, edit, etc...Posted by www.com.au on 2005-12-19 at 09:41:56
ok so say you want to make a form for uploading a file, you do that via a form, which i can do.

After that it gets confusing. as you have to (i beleive) check file types for size and type limits, then copy the file over into another folder so it can be saved permanently.

im not 100% sure on how to do this, i think its something like:

<?php
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
echo "Uploading " . $_FILES["file"]["name"];
echo " (" . $_FILES["file"]["type"] . ", ";
echo ceil($_FILES["file"]["size"] / 1024) . " Kb).<br />";
echo "File is temporarily stored as " . $_FILES["file"]["tmp_name"];
?>

thats for the name, and confirmation of it being stored, but to detect it, is it

if (($_FILES["file"]["type"] == "image/gif") &&
($_FILES["file"]["size"] < 15000)) {

is that it? Like is that correct?

and if so how do i get it to properly copy the file over?
Report, edit, etc...Posted by Shmeeps on 2005-12-20 at 01:27:15
I believe the variables are stored as

$file
$file_name
$file_size
$file_type

not in an array, if memory serves right. Replace $file with whatever variable you're using.

Then, use this

CODE

copy("$file", "/images/$file_name");


Change file you your varialbe's name again. The first argument is the file identifier, and the second is where it's copied to.

You don't have to check for file types, size, ect, but it's useful for limiting stuff.
Next Page (1)