HTML Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   SEO Chat ForumsOtherHTML Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread SEO Chat Forums Sponsor:
  #1  
Old January 17th, 2007, 05:30 PM
jameselder232 jameselder232 is offline
Registered User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 11 jameselder232 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 26 m 15 sec
Reputation Power: 0
Help with a couple of php and html code questions. URGENT!

Hiya basically i have created an smf mod and am now doing the finishing touches. I wish to know how i can do the following and where the code needs to go:

*Prevent click of the submit button if no file is selected (or something like this)
*Prevent overwriting of files, instead rename, them when files with same name are uploaded
*CHMOD copied files automatically so they can be viewed properly (CHMOD setting 755)

Thanks,
james

Reply With Quote
  #2  
Old January 17th, 2007, 06:06 PM
MABDesign's Avatar
MABDesign MABDesign is offline
SEO Ninja
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: Richmond/Raleigh
Posts: 297 MABDesign User rank is Corporal (100 - 500 Reputation Level)MABDesign User rank is Corporal (100 - 500 Reputation Level)MABDesign User rank is Corporal (100 - 500 Reputation Level)MABDesign User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 3 Days 3 h 44 m 13 sec
Reputation Power: 7
You might benefit from doing some homework. I can't answer your questions off-hand, but I'm sure you'd find some useful information in the W3Schools php guide.

http://www.w3schools.com/php/default.asp

Reply With Quote
  #3  
Old January 18th, 2007, 09:43 AM
jameselder232 jameselder232 is offline
Registered User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 11 jameselder232 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 26 m 15 sec
Reputation Power: 0
Quote:
Originally Posted by MABDesign
You might benefit from doing some homework. I can't answer your questions off-hand, but I'm sure you'd find some useful information in the W3Schools php guide.

http://www.w3schools.com/php/default.asp


well i have searched for hours on end using google but with no luck. Sometime it is because i find a way but don't know how to put it into my script sometimes its because i don't fine anything, but will look at that link,

thanks,
james

Reply With Quote
  #4  
Old January 19th, 2007, 12:56 AM
Catacaustic Catacaustic is offline
Contributing User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 130 Catacaustic User rank is Private First Class (20 - 50 Reputation Level)Catacaustic User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 3 Days 17 h 1 m 6 sec
Reputation Power: 6
I'll see if I can give a few pointers in the right direction here...

Quote:
*Prevent click of the submit button if no file is selected (or something like this)
Done with Javascript. Look into "disable" and "enable" there and you'll find something like what you're looking for

Quote:
*Prevent overwriting of files, instead rename, them when files with same name are uploaded

This one's easy. Just get PHP to check if the file exists. If it does, apend something to the end and check if that name exists. Continue until you've found a name that doesn't exist, and save as that.

Quote:
*CHMOD copied files automatically so they can be viewed properly (CHMOD setting 755)

Little bit harder... Can be done in PHP, but usually isn't needed to. Files should have the permissions of 644 and not 755. That means they are viewable by owner, group and world, but only writable by owner. There's no need for a 7 to execute any files, unless you plan on letting people exucute files on your server, which is a HUGE security hole.

Reply With Quote
  #5  
Old January 19th, 2007, 01:58 PM
jameselder232 jameselder232 is offline
Registered User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 11 jameselder232 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 26 m 15 sec
Reputation Power: 0
Quote:
Originally Posted by Catacaustic
I'll see if I can give a few pointers in the right direction here...

Done with Javascript. Look into "disable" and "enable" there and you'll find something like what you're looking for


This one's easy. Just get PHP to check if the file exists. If it does, apend something to the end and check if that name exists. Continue until you've found a name that doesn't exist, and save as that.


Little bit harder... Can be done in PHP, but usually isn't needed to. Files should have the permissions of 644 and not 755. That means they are viewable by owner, group and world, but only writable by owner. There's no need for a 7 to execute any files, unless you plan on letting people exucute files on your server, which is a HUGE security hole.


Hiya thanks for your help, but i have tried following the guide for the javascript in the w3schools link and i cannot work out how to do it, it just doesn't seem to work, and i have tried many other guides as well. Also with the overwrite i don't know much at all about scripting so don't know the codes to put in let alone where to put them. Lastly with the CHMOD, i am not on about CHMODing the uploaded files, but am on about getting my xml script which installs the package in an smf forum, to set the CHMOD for the upload scripts as 755.

Thanks, are you willing to have ago at editing the scripts and emailing them back to me, please? THANKS,
james

Reply With Quote
  #6  
Old January 22nd, 2007, 12:41 AM
Catacaustic Catacaustic is offline
Contributing User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 130 Catacaustic User rank is Private First Class (20 - 50 Reputation Level)Catacaustic User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 3 Days 17 h 1 m 6 sec
Reputation Power: 6
How about you post what you've got here and we'll see if we can get to look at it. As I'm sure you can appreciate, most of us here are professionals, and issues like this are normalyl where we get our income from.

Doesn't mean that I can't help, just that I will see what I can in whatever spare time that I can. So, paste the code that you've already been working on here and I'll see what I can do.

Reply With Quote
  #7  
Old January 23rd, 2007, 10:43 AM
jameselder232 jameselder232 is offline
Registered User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 11 jameselder232 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 26 m 15 sec
Reputation Power: 0
Quote:
Originally Posted by Catacaustic
How about you post what you've got here and we'll see if we can get to look at it. As I'm sure you can appreciate, most of us here are professionals, and issues like this are normalyl where we get our income from.

Doesn't mean that I can't help, just that I will see what I can in whatever spare time that I can. So, paste the code that you've already been working on here and I'll see what I can do.


Thank you! And by the way i am also doing this for others, and doing it in my spare time. As this is a smf mod, and i will be uploading it to the smf mods site as soon as these problems are sorted. Right, the first file is called uploadForm1.php, and it is where the user will accept the terms and conditions & select the number of files being uploaded, can you tell me how i can prevent them clicking submit, if they haven't selected the checkbox to agree to terms and conditions? (checkbox isn't present atm) The coding is:

Code:
<html>
<title>How many files do you wish to upload?</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<STRONG>
<CENTER>
<FONT SIZE=6>
<head>$mbname File Upload</head>
<BR>
<BR>
<body>
<STRONG>
<CENTER>
<FONT SIZE=4>
<BODY BGCOLOR="#99CCFF">
<form name="form1" method="post" action="uploadForm2.php">
  <p>How many files are you uploading? NOTE: The maximum at any one time is 5</p>
  <p>
    <INPUT TYPE=RADIO NAME="uploadNeed" id="uploadNeed" CHECKED VALUE="1">1<BR>
    <INPUT TYPE=RADIO NAME="uploadNeed" id="uploadNeed" VALUE="2">2<BR>
    <INPUT TYPE=RADIO NAME="uploadNeed" id="uploadNeed" VALUE="3">3<BR>
    <INPUT TYPE=RADIO NAME="uploadNeed" id="uploadNeed" VALUE="4">4<BR>
    <INPUT TYPE=RADIO NAME="uploadNeed" id="uploadNeed" VALUE="5">5<BR>
  </p>
<a>By clicking submit you are agreeing to $mbname Upload's T&Cs, which are as follows:
</font><br><form name="form1" > <textarea readonly name="textarea" cols="45" rows="6"> 1. We is not responsible for the safekeeping of any files or folders that are uploaded to our server. Although we will try our best to perform regular back-ups of our file system, we cannot prevent unforseen mishaps, such as suspension of our hosting.

2. No illegal content of any kind is to be uploaded to our server! If we see any illegal content it will be immedaitely deleted and the police may be informed. We keep a record of every ip address from which files are uploaded, so if a file of yours is found to be illegal in any way, we can pass this information onto the police.

3. Our file hosting system is not to be used as a secondary harddrive, it is purely provided to you so you can share some of your favourite files with others across the globe. If any one person is uploading too many files too often, and so we interpret this as an abuse of these terms and conditions, then all of the users files will be deleted.</textarea>
</form>
  <p>
    <input type="submit" name="Submit" value="Submit"><input type="reset" name="Reset Form" value="Reset">
  </p>
</form>
<BR>
<FONT SIZE=2>
<FONT COLOUR="#000000">
<a>Created by James Elder, please visit <A HREF=http://www.chatstop.high-host.net/chatstop>my site</A>
</body>
</html>

Reply With Quote
  #8  
Old January 23rd, 2007, 10:47 AM
jameselder232 jameselder232 is offline
Registered User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 11 jameselder232 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 26 m 15 sec
Reputation Power: 0
This file is called uploadForm2.php, and is where the user selects the files to be uploaded, in this file i wish to prevent them clicking the submit button, if they have selected a file where they should have. The coding is:

Code:
<html>
<title>Select the files you wish to upload...</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<STRONG>
<CENTER>
<FONT SIZE=6>
<head>ChatStop File Upload</head>
<BR>
<BR>
<STRONG>
<FONT SIZE=4>
<CENTER>
<body>
<BODY BGCOLOR="#99CCFF">
<form name="form1" enctype="multipart/form-data" method="post" action="processFiles.php">

  <p>
  <p>Select the file you wish to upload:</p>
      <input type="file" name="uploadFile0" size="50" id="uploadFile0">
  </p>
    <p><input name="uploadNeed" type="hidden" value="1">
    <input type="submit" name="Upload File(s)" value="Submit">
  </p>
</form>
</body>

</html>

Reply With Quote
  #9  
Old January 23rd, 2007, 10:51 AM
jameselder232 jameselder232 is offline
Registered User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 11 jameselder232 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 26 m 15 sec
Reputation Power: 0
This file is called processFiles.php, and it does what it says, processes the uploads. In this file i wish to prevent overwriting of files, and instead wish to rename them, by adding a digit onto the end of their name, before the extension, which increases depending on the number that have been uploaded before. The coding is:

Code:
<title>Thank you for uploading your files, the status of the upload is shown below:</title>
<STRONG>
<CENTER>
<FONT SIZE=6>
<head>$mbname File Upload</head>
<BR>
<BR>
<BODY BGCOLOR="#99CCFF">
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
<STRONG>
<CENTER>
<FONT SIZE=4>
<BODY LINK="#000000">
<?
$uploadNeed = $_POST['uploadNeed'];
// start for loop
for($x=0;$x<$uploadNeed;$x++){
$file_name = $_FILES['uploadFile'. $x]['name'];
// strip file_name of slashes
$file_name = stripslashes($file_name);
$file_name = str_replace("'","",$file_name);
$copy = copy($_FILES['uploadFile'. $x]['tmp_name'],$file_name);
 // check if successfully copied 
if($copy){
 echo "$file_name uploaded sucessfully! <BR>To download use: <A HREF= $boardurl/Uploads/$file_name>this link</A><BR>
<BR> Alternatively copy and paste the following URL into your browser address bar: <BR> 
$boardurl/Uploads/$file_name<BR><HR NOSHADE><BR>";
 }else{
 echo "$file_name could not be uploaded! <BR> Perhaps you didn't select a file, go to <A HREF= $sourcedir/uploadForm1.php>this address</A> to try again<BR><HR NOSHADE><BR>";
 }
} // end of loop
?>
</STRONG>
<BR>
<FONT SIZE=2>
<FONT COLOUR="#000000">
<a>Created by James Elder, please visit <A HREF=http://www.chatstop.high-host.net/chatstop>my site</A>
</CENTER>
</FONT>

Reply With Quote
Reply

Viewing: SEO Chat ForumsOtherHTML Coding > Help with a couple of php and html code questions. URGENT!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek