-
Posts
783 -
Joined
-
Last visited
Everything posted by ZulfadlyAshBurn
-
It is a syntax error! Syntax errors can only be cause by the script not the server.
-
it's not a server error. it's a coding syntax error...
-
Okay let's start from scratch. So firstly we need a form with a file upload function. <form enctype="multipart/form-data" name="submit-cv" id="submit-cv" action="uploadtest.php" method="post"> <table> <tbody> <tr> <td> Your Name: <font color="#DA1623">*</font><br /> <input id="name" class="text" type="text" value="" name="name"> </td> <td> Email Address: <font color="#DA1623">*</font><br /> <input id="email" class="text" type="text" value="" name="email"> </td> </tr> <tr> <td> Telephone: <font color="#DA1623">*</font><br /> <input id="telephone" class="text" type="text" value="" name="telephone"> </td> <td> Location:<br /> <input id="location" class="text" type="text" value="" name="location"> </td> </tr> <tr> <td colspan="2"> Attach CV:<br /> <input name="attachcv" id="file" type="file" /> </td> </tr> <tr> <td colspan="2"> Covering Letter/Other:<br /> <textarea name="coveringletter" rows="5" cols="20"></textarea> </td> </tr> </tbody> </table> <input type="submit" name="submit" value="Send Details"> </form> Next verify if our form is working. I'm just going to echo out the data and upload the file. <?php // here we check if the file is being attached and then upload it to the server if($_FILES['attachcv']['name']) { $target_path = ""; $target_path = $target_path . basename( $_FILES['attachcv']['name']); if(move_uploaded_file($_FILES['attachcv']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['attachcv']['name']). " has been uploaded"; echo "</br>"; } else{ echo "There was an error uploading the file, please try again!"; echo "</br>"; } } else{ echo "The file is not attached!"; echo "</br>"; } // here we get the data from the form $name = Trim(stripslashes($_POST['name'])); $email = Trim(stripslashes($_POST['email'])); $telephone = Trim(stripslashes($_POST['telephone'])); $location = Trim(stripslashes($_POST['location'])); $coveringletter = Trim(stripslashes($_POST['coveringletter'])); // here we echo out the data received echo $name ."</br>"; echo $email."</br>"; echo $telephone."</br>"; echo $location."</br>"; echo $coveringletter."</br>"; echo mime_content_type($_FILES['attachcv']['name']); ?> Okay, try this out. I've tested it and it's working. If it's not working in your end, there might be some server problems.
-
the error doesn't lie on that. there was an error uploading the file thus the mime content type could not get the file.
-
Okay let's try this out. Create a new html file and name it testform.html and insert the following codes <form name="submit-cv" id="submit-cv" action="uploadtest.php" method="post"> <table> <tbody><tr> <td> Your Name: <font color="#DA1623">*</font><br /> <input id="name" class="text" type="text" value="" name="name"> </td> <td> Email Address: <font color="#DA1623">*</font><br /> <input id="email" class="text" type="text" value="" name="email"> </td> </tr> <tr> <td> Telephone: <font color="#DA1623">*</font><br /> <input id="telephone" class="text" type="text" value="" name="telephone"> </td> <td> Location:<br /> <input id="location" class="text" type="text" value="" name="location"> </td> </tr> <tr> <td colspan="2"> Attach CV:<br /> <input type="file" name="attachcv" id="attachcv" /> </td> </tr> <tr> <td colspan="2"> Covering Letter/Other:<br /> <textarea name="coveringletter" rows="5" cols="20"></textarea> </td> </tr> </tbody></table> <input type="submit" name="submit" value="Send Details"> </form> also in the same folder, create a php file and name it uploadtest.php and insert the following code <?php // upload the file to the server $filename = basename( $_FILES['attachcv']['name']); // Where the file is going to be placed $target_path = "uploads/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = $target_path . basename( $_FILES['attachcv']['name']); if(move_uploaded_file($_FILES['attachcv']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['attachcv']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } $file = file_get_contents($target_path); // get posted data into local variables $EmailFrom = "[email protected]"; $EmailTo = "[email protected]"; $Subject = "New Candidate Registration"; $name = Trim(stripslashes($_POST['name'])); $email = Trim(stripslashes($_POST['email'])); $telephone = Trim(stripslashes($_POST['telephone'])); $location = Trim(stripslashes($_POST['location'])); $coveringletter = Trim(stripslashes($_POST['coveringletter'])); // validation $validationOK=true; if (Trim($name)=="") $validationOK=false; if (Trim($email)=="") $validationOK=false; if (Trim($telephone)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=../../error\">"; exit; } // prepare email body text $Body .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n" . "Content-Transfer-Encoding: 7bit\r\n\r\n"; $Body .= ""; $Body .= "Name: "; $Body .= $name; $Body .= "\n"; $Body .= "Email: "; $Body .= $email; $Body .= "\n"; $Body .= "Telephone: "; $Body .= $telephone; $Body .= "\n"; $Body .= "Location: "; $Body .= $location; $Body .= "\n"; $Body .= "Covering Letter: "; $Body .= $coveringletter; $Body .= "\n"; $Body .= "Content-Type: ".mime_content_type($file)."; name=\"" .$target_path. "\"\r\n" . "Content-Transfer-Encoding: base64\r\n" . "Content-disposition: attachment; file=\"" .$target_path. "\"\r\n" . "\r\n" . chunk_split(base64_encode($file)); // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=../../sent\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=../../error\">"; } ?> test out the form and what do you get?
-
How did your get this error? did you fill out the form and try it?
-
Okay, try this code <?php // upload the file to the server $filename = basename( $_FILES['attachcv']['name']); // Where the file is going to be placed $target_path = "uploads/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = $target_path . basename( $_FILES['attachcv']['name']); if(move_uploaded_file($_FILES['attachcv']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['attachcv']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } $file = file_get_contents($target_path); // get posted data into local variables $EmailFrom = "[email protected]"; $EmailTo = "[email protected]"; $Subject = "New Candidate Registration"; $name = Trim(stripslashes($_POST['name'])); $email = Trim(stripslashes($_POST['email'])); $telephone = Trim(stripslashes($_POST['telephone'])); $location = Trim(stripslashes($_POST['location'])); $coveringletter = Trim(stripslashes($_POST['coveringletter'])); // validation $validationOK=true; if (Trim($name)=="") $validationOK=false; if (Trim($email)=="") $validationOK=false; if (Trim($telephone)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=../../error\">"; exit; } // prepare email body text $Body .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n" . "Content-Transfer-Encoding: 7bit\r\n\r\n" $Body .= ""; $Body .= "Name: "; $Body .= $name; $Body .= "\n"; $Body .= "Email: "; $Body .= $email; $Body .= "\n"; $Body .= "Telephone: "; $Body .= $telephone; $Body .= "\n"; $Body .= "Location: "; $Body .= $location; $Body .= "\n"; $Body .= "Covering Letter: "; $Body .= $coveringletter; $Body .= "\n"; $Body .= "Content-Type: ".mime_content_type($file)."; name=\"" .$target_path. "\"\r\n" . "Content-Transfer-Encoding: base64\r\n" . "Content-disposition: attachment; file=\"" .$target_path. "\"\r\n" . "\r\n" . chunk_split(base64_encode($file)); // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=../../sent\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=../../error\">"; } ?>
-
That's the exact same thing. Make sure you have the folder called upload. Your script is not uploading the file as there was an error uploading it. Try small files.
-
You must make sure that the file is uploaded properly. Your error shows "There was an error uploading the file, please try again!".
-
It's unable to call the mime_content_type() because the file has an error in uploading. If the file is not uploaded, the script is not able to call what type of file is being uploaded.
-
It's okay! Goodluck!
-
What is the code you currently have?
-
No problem
-
You have to store the value in the variable before saving it in the session. use this session_start(); $fruits = array('apple', 'banana', 'pear'); $_SESSION['fruits'] = $fruits; session_start(); echo $_SESSION['fruits'][3]; before you try out the script, clear your session first using. create a new php file and run it <?php session_destroy(); ?> this will ensure it destroys all the previous session used.
-
the form actions should be <?php echo '<form name="contactform" action="'.$_SERVER['PHP_SELF'].'" method="post">'; ?>
-
Ruby - Sign in with twitter // Twitter OAuth
ZulfadlyAshBurn replied to smithmr8's topic in Other Programming Languages
I have a feeling you are not allowed to use your localhost to request tokens ? -
If you want people to help you code the script, you can find help in the freelance section or pm if you need me to do it. Usually you have to pay up some cash or they might offer you for free.
-
If they uses the same domain and server, you can use session. Or else you have to use PHP GET to transfer the details.
-
It's pretty much easy if you know how the fundamentals of php and html. 1) Learn html to create a form with upload 2) Use php to save the title and the location/name of the file in the DATABASE 3) Use php to upload the files to server. The rest are pretty much straight forward.
-
So you basically want to create a file manager for a text file?
-
This should work just fine. I have not personally tested it out. But it looks fine <?php // upload the file to the server $filename = basename( $_FILES['uploadedfile']['name']); // Where the file is going to be placed $target_path = "uploads/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = $target_path . basename( $_FILES['file']['name']); if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['file']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } $file = file_get_contents($target_path); // get posted data into local variables $EmailFrom = "[email protected]"; $EmailTo = "[email protected]"; $Subject = "New Candidate Registration"; $name = Trim(stripslashes($_POST['name'])); $email = Trim(stripslashes($_POST['email'])); $telephone = Trim(stripslashes($_POST['telephone'])); $location = Trim(stripslashes($_POST['location'])); $coveringletter = Trim(stripslashes($_POST['coveringletter'])); // validation $validationOK=true; if (Trim($name)=="") $validationOK=false; if (Trim($email)=="") $validationOK=false; if (Trim($telephone)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=../../error\">"; exit; } // prepare email body text $Body .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n" . "Content-Transfer-Encoding: 7bit\r\n\r\n" $Body .= ""; $Body .= "Name: "; $Body .= $name; $Body .= "\n"; $Body .= "Email: "; $Body .= $email; $Body .= "\n"; $Body .= "Telephone: "; $Body .= $telephone; $Body .= "\n"; $Body .= "Location: "; $Body .= $location; $Body .= "\n"; $Body .= "Covering Letter: "; $Body .= $coveringletter; $Body .= "\n"; $Body .= "Content-Type: ".mime_content_type($file)."; name=\"" .$target_path. "\"\r\n" . "Content-Transfer-Encoding: base64\r\n" . "Content-disposition: attachment; file=\"" .$target_path. "\"\r\n" . "\r\n" . chunk_split(base64_encode($file)); // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=../../sent\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=../../error\">"; } ?> I've just updated the code. Saw some syntax errors.
-
this might help <?php $type = mime_content_type($file); ?> it would produce the file type of the file.
-
Check out this tutorial.
-
Ouh. I'll alert the devs. In the mean time, if you see any changes which are weird, please do reply to this topic. They recently had a new server.
-
I have to agree that you must learn the fundamentals of JS before moving to jQuery. But jQuery helps shorten your script and there are many functions you could do with it. If I've solved your JS problems, please marked this topic as solved on the bottom of this page.