Jump to content

joshgarrod

Members
  • Posts

    283
  • Joined

  • Last visited

    Never

Everything posted by joshgarrod

  1. Thank you, I appreciate your help. I looked more into mime types which I had not really come accross before having only worked with images in the past. I changed "application/doc" to "application/msword" and it works! Thanks again.
  2. Thanks very much for your replies. It has worked for PDF but not for DOC.
  3. Hi, I have a script that currently works for uploading images and I have tried to modify it to upload PDF's and DOC's too, but I can't get it to work - it works fine with JPG or GIF. Any ideas? Thanks in advance. <?php include "scripts/connect.php"; $idir = "../documents/"; // Path To Images Directory if (isset ($_FILES['fupload'])){ $randomd=rand(0000,9999); //upload the image to tmp directory $url = $_FILES['fupload']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload']['type'] == "image/jpg" || $_FILES['fupload']['type'] == "image/jpeg" || $_FILES['fupload']['type'] == "image/pjpeg" || $_FILES['fupload']['type'] == "image/gif" || $_FILES['fupload']['type'] == "image/pdf" || $_FILES['fupload']['type'] == "image/doc") { $file_ext = strrchr($_FILES['fupload']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload']['tmp_name'], "$idir" . "$randomd" . $_FILES['fupload']['name']); // Move Image From Temporary Location To Permanent Location } } error_reporting (E_ALL ^ E_NOTICE); if ($_POST['submit']) { $document = mysql_real_escape_string("$idir" . "$randomd" . $_FILES['fupload']['name']); $name = mysql_real_escape_string($_POST['name']); $description = mysql_real_escape_string($_POST['description']); $SQL = " INSERT INTO documents"; $SQL .= " (document, name, description) VALUES "; $SQL .= " ('$document', '$name', '$description') "; $result = mysql_db_query($db,$SQL,$cid); $last=mysql_insert_id(); if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); } header("location:document-added.php?ref=$last"); exit(); } ?>[code]
  4. Hi all, I am trying to get a popup javascript calendar working on my form. I have the demo working perfectly on my machine but when i try and add to my site and test in IE I click on the calenndar icon which calls the function to start the calendar and nothing happens. in the bottom corner of IE it informs me there are errors on the page. The error is that "Object Require calendar.js". The script is being sourced in the header of my page at the correct location... any ideas as to where I am going wrong? Thanks in advance: <head> <script language="javaScript" type="text/javascript" src="js/calendar.js"></script> <link href="css/calendar.css" rel="stylesheet" type="text/css"> </head> <form name="fa" action="add-calendar-date.php" method="POST" enctype="multipart/form-data"> <div class="field-hold"> <div class="field-name">Calendar Date Title:</div> <div class="field"><input name="title" type="text" id="title" value="" size="60" /> </div></div> <div class="field-hold"> <div class="field-name">Calendar Date Description:</div> <div class="field"><textarea name="description" cols="45" rows="10" id="description" type="text" value="" /></textarea></div></div> <div class="field-hold"> <div class="field-name">Start Date:</div> <div class="field"><input name="startdate" type="text" id="startdate" value="" size="30" /> <a href="#" onClick="setYears(2011, 2020); showCalender(this, 'startdate');"><img src="images/calendar.png" border="0"></a> </div></div> <div class="field-hold"> <div class="field-name">End Date:</div> <div class="field"><input name="enddate" type="text" id="enddate" value="" size="30" /> <a href="#" onClick="setYears(2011, 2020); showCalender(this, 'enddate');"><img src="images/calendar.png" border="0"></a> </div></div> <div class="field-hold"> <div class="field-name">Start Time:</div> <div class="field"><input name="starttime" type="text" id="starttime" value="" size="30" /> </div></div> <div class="field-hold"> <div class="field-name">End Time:</div> <div class="field"><input name="endtime" type="text" id="endtime" value="" size="30" /> </div></div> <div class="field-hold"> <div class="field-name">Author:</div> <div class="field"><input name="author" type="text" id="author" value="" size="30" /> </div></div> <input name="submit" type="submit" value="Add Calendar Date" /> </form>
  5. Hi, I am having an issue with a piece of code. I am getting the following error, any ideas please? <?php include "scripts/connect.php"; $last = $_GET['ref']; // This will be the ID of the page echo "the ref number is $last"; $query = mysql_query("SELECT * FROM news WHERE `ref` = '$last'"); if(mysql_num_rows($query)==0){ die("Something went wrong, contact Administrator!"); }else{ while($info = mysql_fetch_array($query)){ $title = $info ['title']; echo "<p><a href=\"..news.php\" target=\"_blank\">$title >></a></p>"; } } ?>
  6. Okay, I understand what you are saying. I just wondered if there were any pre-written open source scripts out there that I may be able to disect.
  7. Bascially, I am writing a CMS and the user needs to be able to upload PDF, Doc and XLS files so I need to create an HTML form that uses a PHP script to upload these documents to the server and places a record in the database table to log its name. I hope this is enough info. Thank for your time.
  8. Hi everyone. I have been looking for a PHP upload script that handles various different document types like PDF, DOC and XLS. So far all I have found is image upload scripts. Can anyone point me in the right direction? I would be most greatful. Thank you!
  9. Hi, I am trying to get the background of a div to change when the user is typing in the textfield inside it... sadly I cannot get it to work. Could someone please help me solve this? Thanks in advance... Javascript function changebg() { var docEl = this.parentNode.getElementsByTagName('greenhighlight'); docEl.style.backgroundImage = "url('images/form-highlight-bg.jpg')"; } css .greenhighlight {float:left; width:980px; height:60px;} html <fieldset> <div class="greenhighlight"> <span class="hint">The contact name is the name of the person who is to receive the enquiries for the adverts we submit. This field is required.</span> <label for="contactname"><strong>* Contact Name:</strong></label> <input type="text" id="contactname" onFocus="changebg(greenhighlight);"/> </div> </fieldset>
  10. cheers for that, exactly what I wanted - PHP really does have an answr for everything!
  11. Thats awesome thanks I will try that. $php_mysql$ - I am using a textarea to pull the data from
  12. Yes but that appears to need someone to type \n... how do I get it to do it itself?
  13. Hi all, I am hoping I am able to explain this so here goes: I have a form which inserts data into a table, one field is a textarea. When typing in the textarea you can hit enter to start a new paragraph. But when I pull this info from the database and display it, it appears in one large clump. How do I get PHP to recognise the paragraph? Thanks in advance.
  14. Hi, I am trying to find a piece of databse management software that I can edit locally and syncronise with the live version when needed. I currently use DreamCoder but it is not great. Can anyone suggest anything? Thanks, Josh
  15. Hi, thanks for the reply... Im sorry I do not quite understand how you mean?
  16. Hi all, I have an issue with an image upload script. So far the script will upload the image to the server and rename it with a random 5 digit number on the end. I then INSERT this data into a table for sourcing the image later on. the only problem is that the data in the table is the image's original name not the new one. how do I get it to change that name too? Thanks. <?php $idir = "uploads/"; // Path To Images Directory if (isset ($_FILES['fupload'])){ //upload the image to tmp directory $url = $_FILES['fupload']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload']['type'] == "image/jpg" || $_FILES['fupload']['type'] == "image/jpeg" || $_FILES['fupload']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload']['tmp_name'], $idir. basename($_FILES['fupload']['name'], $file_ext).rand(10000 , 99999).$file_ext); // Move Image From Temporary Location To Perm } } error_reporting (E_ALL ^ E_NOTICE); $usr = "user"; $pwd = "pword"; $db = "db"; $host = "host"; # connect to database $cid = mysql_connect($host,$usr,$pwd); if (!$cid) { echo("ERROR: " . mysql_error() . "\n"); } if ($_POST['submit']) { $logo = mysql_real_escape_string("$idir" . $_FILES['fupload']['name']); $SQL = " INSERT INTO mhhire "; $SQL .= " (logo) VALUES "; $SQL .= " ('$logo') "; $result = mysql_db_query($db,$SQL,$cid); $last=mysql_insert_id(); if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); } header("location:thanks.php"); exit(); } ?>
  17. hi mjdamato, I do want both the record in the database and the name of the image to be the same - how do I achieve this at the moment the image is saved to the server with the 5 digit number on the end but not in the database. Sorry I am a bit out of my depth with all this.
  18. Sorry, I don't understand... I thought I was saving the image name to a variable in the form of $logo, $image1, $image2 and $image3 which I am then inserting?
  19. Okay, I take on board your points. I am getting no errors just that my uploaded image on the server is called "image12345.jpg" and the image source in my table is being recorded as "image.jpg". I could use a variable $account which is defined early on in the script, this is a unique account number that each user will have and this will ensure no collisions. how would I add $account to the end of the image name? Thanks for your help
  20. Hi, I have a script to add images to my tabel and and upload them to my server, I have managed to get the upload script to rename the image with a 5 digit random number on the end to prevent overwriting, the only problem I can't seem to be able to add the same name to my tabel. Any ideas? Thanks in advance. <?php $idir = "uploads/"; // Path To Images Directory if (isset ($_FILES['fupload'])){ //upload the image to tmp directory $url = $_FILES['fupload']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload']['type'] == "image/jpg" || $_FILES['fupload']['type'] == "image/jpeg" || $_FILES['fupload']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload']['tmp_name'], $idir. basename($_FILES['fupload']['name'], $file_ext).rand(10000 , 99999).$file_ext); // Move Image From Temporary Location To Perm } } if (isset ($_FILES['fupload2'])){ //upload the image to tmp directory $url = $_FILES['fupload2']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload2']['type'] == "image/jpg" || $_FILES['fupload2']['type'] == "image/jpeg" || $_FILES['fupload2']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload2']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload2']['tmp_name'], "$idir" . $_FILES['fupload2']['name'] $file_ext).rand(10000 , 99999).$file_ext); // Move Image From Temporary Location To Permanent Location } } if (isset ($_FILES['fupload3'])){ //upload the image to tmp directory $url = $_FILES['fupload3']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload3']['type'] == "image/jpg" || $_FILES['fupload3']['type'] == "image/jpeg" || $_FILES['fupload3']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload3']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload3']['tmp_name'], "$idir" . $_FILES['fupload3']['name'] $file_ext).rand(10000 , 99999).$file_ext); // Move Image From Temporary Location To Permanent Location } } if (isset ($_FILES['fupload4'])){ //upload the image to tmp directory $url = $_FILES['fupload4']['name']; // Set $url To Equal The Filename For Later Use if ($_FILES['fupload4']['type'] == "image/jpg" || $_FILES['fupload4']['type'] == "image/jpeg" || $_FILES['fupload4']['type'] == "image/pjpeg") { $file_ext = strrchr($_FILES['fupload4']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php $copy = copy($_FILES['fupload4']['tmp_name'], "$idir" . $_FILES['fupload4']['name'] $file_ext).rand(10000 , 99999).$file_ext); // Move Image From Temporary Location To Permanent Location } } $usr = "user"; $pwd = "pass"; $db = "db"; $host = "host"; # connect to database $cid = mysql_connect($host,$usr,$pwd); if (!$cid) { echo("ERROR: " . mysql_error() . "\n"); } if ($_POST['submit']) { $logo = mysql_real_escape_string("$idir" . $_FILES['fupload']['name']); $image1 = mysql_real_escape_string("$idir" . $_FILES['fupload2']['name']); $image2 = mysql_real_escape_string("$idir" . $_FILES['fupload3']['name']); $image3 = mysql_real_escape_string("$idir" . $_FILES['fupload4']['name']); $SQL = " INSERT INTO mhhire "; $SQL .= " image1, image2, image3, logo) VALUES "; $SQL .= " ('$image1', '$image2', '$image3', '$logo') "; $result = mysql_db_query($db,$SQL,$cid); $last=mysql_insert_id(); if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); } header("location:thanks.php"); exit(); } ?>
  21. exactly, basically stripping off the ../ from the image path if it has one, if not then leave the image path
  22. Yes but I dont want to change the contents to anything if it doesn't contain ../ - can I just tell it do nothing?
  23. Hi BlueSkyIS, $logo contains: logo: ../uploads/pretendloog.jpg - with those alterations it performs as before. Hi Paul Ryan, that almost works but how do I stop NULL from replacing the contents of the variable if ../ is not present? Thanks for your time all
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.