upload form file types....
Posted on
16th Feb 2014 07:03 pm by
admin
Hey all, I am learning PHP and I am writing a script from the W3C Schools tutorials for uploading files to my server. I want to be able to use it for a friend to upload files to my server (I know to be careful). I only want it to be able to allow those images, exe, rar and zip files, no ISO's, .IMG's etc... I understand how the code works and have added and extra image file extension, but how would I add .exe, .zip and .rar? I thought maybe app/exe etc... and tried it, but I don't think it worked, files aren't being uploaded other than the images. All my permissions are set right and my test files sizes are ok.
What I am is asking is what is the code to allow those 3 file types to be uploaded?
Here is my code:
Code: <?php
if (((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/pjpeg")))
&& ($_FILES["file"]["size"] < 8000000))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
?>
No comments posted yet
Your Answer:
Login to answer
100
10
Other forums
help connecting a form to php and then emailing the form
Ok. So, I made a form, and I need help to where when submitted, I get an email with the submitted de
email form (cannot find the problem)
Hello there. I've been having trouble with an email form. Can't find the problem really. I've tested
PDO returns erroneous columns from within pdt
Hi All,
This is a truly weird behavior:
When using a simple pdo fetch, erroneous columns a
quotes changing
hi all
in my content
opening quotes " changes to “
close qu
2 decima places & How to reload my page
Hello There,
How do i put full-stop (.) after second figure from behind? ie if i have 123456
column name cancatenation within PL/SQL
I have a PLSQL store procedure, and the following statement is part of a subquery
fname||lnam
How to login with SAPCPIC userid
I have changed the Password for SAPCPIC in Development Server for 000,001 and 100 client.
But w
Receive Rosettanet Message to SAP 4.6c
Dear all ,
My customer will send the PO details by rosettanet message , Is it
pointer 102 question
I read a book
1
2
3
4
5
6
7
8
9
10
11
12
int main()
{
default SAP userid
hi,, I just like to know if it is ok to use the default SAP user id (SAP*)?