Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

154 users online



PHP upload

PHP upload

Currently viewing this thread: 1 (0 members and 1 guests)


Page 1 out of 3
marf

marf

Marf
Status: Offline!

PHP upload

I recently used the tutorial on this page http://robouk.mchost.com/tuts/tutorial.php?tutorial=fileupload

when I had a WinXP server. I found it easy and effective but windows was limiting me because i couldn't set file permissions. So i decided to Install linux, and by golly, It's Fantastic. I got FTP, Apache, Samba, DNS, SMTP, IMAP, POP3 and Webmail all up and working. And now I can set file permissions, and the upload script from the tutorial works now. However there is one restriction i would like to know how to add. This upload tutorial doesn't limit what file type to upload. I would like to be able to only let .ZIP files 1MB or less to be uploaded. CAn anybody point me in the right direction?? or tell me how to add this funciton to the php script?

thanks

Michael

___________________

http://www.infinitedesigns.org/signature.jpg

Jubba

Jubba

Status: Offline!

just check the file name

PHP:

<?php

$tmp_name 
$_FILES['userfile']['tmp_name'];

if(
substr($tmp_name, -3) == "zip"){
// execute code...
}
?>

something like that worked for me...

epyon

epyon

16, staying Asian.
Status: Offline!

it's better if you check the mime type cause i can just rename the file to have .zip

PHP:

<?php
if($_FILES['userfile']['type'] != "application/zip") {
echo 
"this ain't no zip";
} else {
// upload code
}
?>

___________________

http://whatpulse.bounceme.net/sig/epyon.png

Motorspin

Motorspin

Neverside Newbie
Status: Offline!

Nice error message, ep, I like it.

___________________

Travis Farrell
http://motorspin.com/stuff/images/avasig/m_enterprisesig.gif

Jubba

Jubba

Status: Offline!

true. good call. I'm used to working for morons that don't know how to rename files so that never really was a problem. Smile

marf

marf

Marf
Status: Offline!

hrm.

I tried to add that code you said and heres what i have.

Code:


<?php

if($_FILES['userfile']['type'] != "application/zip") {
echo "this ain't no zip";
} else {
if(!(copy($_FILES['userfile']['tmp_name'], "uploads/" . $_FILES['userfile']['name']))) die("Cannot upload files.");
echo "Upload Complete!";
}
?>

now even if i try to upload a zip file, it says "this ain't no zip!"

any help?

___________________

http://www.infinitedesigns.org/signature.jpg

Millo

Millo

Status: Offline!

Hey is there anyway you could extend on this and tell us how to make a page that will show the most recent uploads or somthing im kind of a noob

___________________

// RANKING = n00b \\

Motorspin

Motorspin

Neverside Newbie
Status: Offline!

Yep... it's called a search.

___________________

Travis Farrell
http://motorspin.com/stuff/images/avasig/m_enterprisesig.gif

Millo

Millo

Status: Offline!

no i want like a page to post the most recent uploads that have been uploaded..... And if possible on the main page.

___________________

// RANKING = n00b \\

marf

marf

Marf
Status: Offline!

*cough*
can we get back to why my code isn't working?? Smile

thanks

___________________

http://www.infinitedesigns.org/signature.jpg

Page 1 out of 3
Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0095 seconds.