SEO | Link Popularity | Search Engine Consulting | SEO Tutorial | SEO Tools | SEO Forum
 
 
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-27-2006, 08:04 AM
jlknauff's Avatar
jlknauff jlknauff is offline
SEO GUY Moderator
 
Join Date: May 2004
Location: In perpetual style
Posts: 3,312 jlknauff is on a distinguished road
php upload form + remove spaces

I have a form here: http://www.wildfiremarketinggroup.com/form1.html

And have added a bit of code that I thought was correct (line 3) to replace spaces with and underscore because if someone uploaded a file with a space in the name, the link to it on the server got broken. In any case, it doesn't work.

Here is my php:

Code:
<?php
include("global.inc.php");
$temp = str_replace(" "_"", $temp);
echo $temp;
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','Contactname');
pt_register('POST','Phonenumber');
pt_register('POST','Emailaddress');
$File1=$HTTP_POST_FILES['File1'];
$File2=$HTTP_POST_FILES['File2'];
$File3=$HTTP_POST_FILES['File3'];
$File4=$HTTP_POST_FILES['File4'];
$File5=$HTTP_POST_FILES['File5'];
$File6=$HTTP_POST_FILES['File6'];
$Comments=$HTTP_POST_FILES['Comments'];
if($Contactname=="" || $Phonenumber=="" || $Emailaddress=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if($HTTP_POST_FILES['File1']['tmp_name']==""){ }
 else if(!is_uploaded_file($HTTP_POST_FILES['File1']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['File1']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['File2']['tmp_name']==""){ }
 else if(!is_uploaded_file($HTTP_POST_FILES['File2']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['File2']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['File3']['tmp_name']==""){ }
 else if(!is_uploaded_file($HTTP_POST_FILES['File3']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['File3']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['File4']['tmp_name']==""){ }
 else if(!is_uploaded_file($HTTP_POST_FILES['File4']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['File4']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['File5']['tmp_name']==""){ }
 else if(!is_uploaded_file($HTTP_POST_FILES['File5']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['File5']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['File6']['tmp_name']==""){ }
 else if(!is_uploaded_file($HTTP_POST_FILES['File6']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['File6']['name'].", was not uploaded!";
$errors=1;
}
if($HTTP_POST_FILES['Comments']['tmp_name']==""){ }
 else if(!is_uploaded_file($HTTP_POST_FILES['Comments']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['Comments']['name'].", was not uploaded!";
$errors=1;
}
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$Emailaddress)){
$error.="<li>Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['File1']['name'];
$image_list[3] = $image_part;
copy($HTTP_POST_FILES['File1']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['File2']['name'];
$image_list[4] = $image_part;
copy($HTTP_POST_FILES['File2']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['File3']['name'];
$image_list[5] = $image_part;
copy($HTTP_POST_FILES['File3']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['File4']['name'];
$image_list[6] = $image_part;
copy($HTTP_POST_FILES['File4']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['File5']['name'];
$image_list[7] = $image_part;
copy($HTTP_POST_FILES['File5']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['File6']['name'];
$image_list[8] = $image_part;
copy($HTTP_POST_FILES['File6']['tmp_name'], "files/".$image_part);
$image_part = date("h_i_s")."_".$HTTP_POST_FILES['Comments']['name'];
$image_list[9] = $image_part;
copy($HTTP_POST_FILES['Comments']['tmp_name'], "files/".$image_part);
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="Contact name: ".$Contactname."
Phone number: ".$Phonenumber."
Email address: ".$Emailaddress."

File 1: ".$where_form_is."files/".$image_list[3]."
File 2: ".$where_form_is."files/".$image_list[4]."
File 3: ".$where_form_is."files/".$image_list[5]."
File 4: ".$where_form_is."files/".$image_list[6]."
File 5: ".$where_form_is."files/".$image_list[7]."
File 6: ".$where_form_is."files/".$image_list[8]."
Comments: ".$where_form_is."files/".$image_list[9]."
";
$message = stripslashes($message);
mail("print@wildfiremarketinggroup.com","File upload form",$message,"From: $Email");

header("Refresh: 0;url=http://www.wildfiremarketinggroup.com");
?><?php 
}
?>


Any ideas? Also - the script needs to be able to upload large files (>10mb). Is this a setting on the server that needs to be changed or am I taking the wrong approach here?
__________________
Wildfire Marketing Forum - Visit our free marketing forum to learn and share tips about marketing.
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Login/Register
User Name
Password
Remember Me?

Forum Links
Forum Home
SEO Forum
Internet Marketing Forum
Web Design Forum
Web Hosting Forum
Programming Forum
SEO Chat

Quick Links
Forum Home
New Posts
Mark Forums Read
Open Buddy List
User Control Panel
Edit Avatar
Edit Profile
Edit Options
Miscellaneous
Subscribed Threads
My Profile

Search Forums

Advanced Search
All times are GMT -8. The time now is 03:04 PM.


Powered by: vBulletin Version 3.0.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.