Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 08-18-2008, 11:46 AM   #1
snowpimp
Confirmed User
 
Join Date: Feb 2002
Location: South Lake Tahoe, CA
Posts: 1,099
please help me with simple php

can someone help me add file types to my upload script please?

current it checks for jpeg and errors if it's not that one type:

if ($type == "image/jpeg"){


i want to add supported file types so i've changed it to:
if ($type == "image/jpeg")
|| ($type == "image/jpg")
|| ($type == "image/gif")
|| ($type == "image/psd")
|| ($type == "image/tiff")
|| ($type == "image/bmp")

{

but it's not happy...
__________________
HIGH QUALITY ADULT AND NON-ADULT DESIGN/MARKETING WORK SINCE 1997!!

Yan - ICQ # 4790444 - Phone: 530-544-7058

snowpimp is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-18-2008, 11:54 AM   #2
just a punk
So fuckin' bored
 
just a punk's Avatar
 
Industry Role:
Join Date: Jun 2003
Posts: 32,384
That should work, but it depends on what exactly is stored in $type variable.
__________________
Obey the Cowgod
just a punk is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-18-2008, 11:56 AM   #3
Aric
Confirmed User
 
Aric's Avatar
 
Industry Role:
Join Date: Sep 2002
Posts: 1,209
PHP Code:
$allowed_types = array("image/jpeg""image/jpg""image/gif""image/psd","image/tiff","image/bmp");
if (
in_array($type$allowed_types)) {
    
do_something;

__________________
Awesome cloud hosting by DigitalOcean
Aric is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-18-2008, 11:57 AM   #4
Bro Media - BANNED FOR LIFE
MOBILE PORN: IMOBILEPORN
 
Join Date: Jan 2004
Location: Tinseltown NL
Posts: 16,502
Quote:
Originally Posted by cyberxxx View Post
That should work, but it depends on what exactly is stored in $type variable.
bingo. whats $type ?
Bro Media - BANNED FOR LIFE is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-18-2008, 11:59 AM   #5
snowpimp
Confirmed User
 
Join Date: Feb 2002
Location: South Lake Tahoe, CA
Posts: 1,099
$type = $_FILES['filename']['type'];
__________________
HIGH QUALITY ADULT AND NON-ADULT DESIGN/MARKETING WORK SINCE 1997!!

Yan - ICQ # 4790444 - Phone: 530-544-7058

snowpimp is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-18-2008, 12:06 PM   #6
just a punk
So fuckin' bored
 
just a punk's Avatar
 
Industry Role:
Join Date: Jun 2003
Posts: 32,384
Quote:
Originally Posted by snowpimp View Post
$type = $_FILES['filename']['type'];
Should be working then. Are you getting any error message?
__________________
Obey the Cowgod
just a punk is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-18-2008, 12:33 PM   #7
snowpimp
Confirmed User
 
Join Date: Feb 2002
Location: South Lake Tahoe, CA
Posts: 1,099
thanks for your help!

here's the page it's on and the error:
http://www.cheaptrace.com/contact.html

Parse error: parse error, unexpected T_BOOLEAN_OR in /home/httpd/cheaptrace.com/html/sendmail.php on line 58


here's the whole script:
<?php
session_start();
if ($_POST["vercode"] != $_SESSION["vercode"] OR $_SESSION["vercode"]=='') {
echo '<strong>Incorrect verification code.</strong><br>';
die;
} else {
if ($_SERVER['REQUEST_METHOD']=="POST"){
$sendername = $_POST['name'];
$from = $_POST['mail'];
$senderphone = $_POST['phone'];
$sendercountry = $_POST['country'];
$filename = basename($_FILES['filename']['name']);
$ext = substr($filename, strrpos($filename, '.') + 1);
$notes = $_POST['remarks'];
$to="[email protected]";
$subject="Cheap Trace";
/*$from = stripslashes($_POST['fromname'])."<".stripslashes($_POST['fromemail']).">";*/
$mime_boundary="==Multipart_Boundary_x".md5(mt_ran d())."x";
$tmp_name = $_FILES['filename']['tmp_name'];
$type = $_FILES['filename']['type'];
$name = $_FILES['filename']['name'];
$size = $_FILES['filename']['size'];
$message = "Filename: $name\n";
$message .="type: $type\n";
$message .="size: $size\n\n";
if (file_exists($tmp_name)){
if(is_uploaded_file($tmp_name)){
$file = fopen($tmp_name,'rb');
$data = fread($file,filesize($tmp_name));
fclose($file);
$data = chunk_split(base64_encode($data));
}
$message .= "Name: "."$sendername\n";
$message .= "Country: "."$sendercountry\n";
$message .= "EMail Address: "."$from\n";
$message .= "Telephone: "."$senderphone\n\n";
$message .= "Remarks: "."$notes\n\n";

$headers = "From: $from\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: multipart/mixed;\r\n" .
" boundary=\"{$mime_boundary}\"";

$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";

$message .= "--{$mime_boundary}\n" .
"Content-Type: {$type};\n" .
" name=\"{$name}\"\n" .

"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
if ($type == "image/jpeg")
|| ($type == "image/jpg")
|| ($type == "image/gif")
|| ($type == "image/psd")
|| ($type == "image/tiff")
|| ($type == "image/bmp")

{

}else{
echo "The file is not a supported file type: jpeg, jpg, gif, psd, tiff or bmp";
die;
}
if (@mail($to, $subject, $message, $headers))
echo "Your request has been sent.<br>";
else
echo "Failed to send";
}
} else {
?>
<meta http-equiv="refresh" content="2;URL=contact.html">
<?php }
}
?>
__________________
HIGH QUALITY ADULT AND NON-ADULT DESIGN/MARKETING WORK SINCE 1997!!

Yan - ICQ # 4790444 - Phone: 530-544-7058

snowpimp is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-18-2008, 12:38 PM   #8
Aric
Confirmed User
 
Aric's Avatar
 
Industry Role:
Join Date: Sep 2002
Posts: 1,209
Quote:
if ($type == "image/jpeg")
|| ($type == "image/jpg")
|| ($type == "image/gif")
|| ($type == "image/psd")
|| ($type == "image/tiff")
|| ($type == "image/bmp")
It's a bracketing problem.

if ($type == "image/jpeg"
|| $type == "image/jpg"
|| $type == "image/gif"
|| $type == "image/psd"
|| $type == "image/tiff"
|| $type == "image/bmp")
__________________
Awesome cloud hosting by DigitalOcean
Aric is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-18-2008, 12:40 PM   #9
UniqueD
Confirmed User
 
UniqueD's Avatar
 
Industry Role:
Join Date: Aug 2004
Location: Barcelona
Posts: 1,022
^ absolutely correct.
UniqueD is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-18-2008, 12:54 PM   #10
snowpimp
Confirmed User
 
Join Date: Feb 2002
Location: South Lake Tahoe, CA
Posts: 1,099
sweet thanks guys
__________________
HIGH QUALITY ADULT AND NON-ADULT DESIGN/MARKETING WORK SINCE 1997!!

Yan - ICQ # 4790444 - Phone: 530-544-7058

snowpimp is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.