|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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 |
|
#3
|
|||
|
|||
|
Quote:
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 |
|
#4
|
|||||
|
|||||
|
I'll see if I can give a few pointers in the right direction here...
Quote:
Quote:
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:
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. |
|
#5
|
|||
|
|||
|
Quote:
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 |
|
#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. |
|
#7
|
|||
|
|||
|
Quote:
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>
|
|
#8
|
|||
|
|||
|
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>
|
|
#9
|
|||
|
|||
|
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>
|
![]() |
| Viewing: SEO Chat Forums > Other > HTML Coding > Help with a couple of php and html code questions. URGENT! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|