Jump to content

kurt.santo

Members
  • Content Count

    925
  • Joined

  • Last visited

Community Reputation

0 Neutral

About kurt.santo

  • Rank
    Invested Member
  1. Thats good to know. Thanks for all inputs...Kurt
  2. Do you know why they wrap it up in two <script /> tags?Kurt
  3. I have a code given by Google to include in website code, but I would like to understand first what it does. The code is: <script type="text/javascript">var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));</script><script type="text/javascript">var pageTracker = _gat._getTracker("UA-1982198-7");pageTracker._initData();pageTracker._trackPageview();</script> Does someone know what it does and is this to be
  4. I thought about a loop before, but then the problem comes in tha the db query should only be run once. I really do not have a clue in how to amend that it loops through my images, but it only does once db insert query. The code as it is: if (isset($_FILES['img1'])) { // validate the input global $ext; global $ext2; if(in_array($ext, $allowed) && in_array($ext2, $allowed)) { // move the file over if(move_uploaded_file($_FILES['img1']['tmp_name'], "{$images}{$img1}")) { echo '<p>file 1 has been uploaded ok</p>'; } else { echo '<p>file 1 upload did not wo
  5. Corrected and page displays. But now I realise another conceptual error I made. For the upload to work fine both files have to be uploaded. THis is not what I want. Only one is mandatory ($img1). Can I somehow amend line:if(in_array($ext, $allowed) && in_array($ext2, $allowed)) { so it only tests for $ext2 if $img2 is not FALSE (which is the complete file name including extension if it passed validation)?Kurt
  6. Use now: $ext = explode('.',$_FILES['img1']['name']); $ext = $ext[count($ext)-1]; which seems to do the trick... Thank you!Kurt
  7. I use the following code to move two files to permanent location while inserting their name in db table. IT works fine as long as you do not try to upload the wrong file type for second file. // check for img1 if (!isset($_FILES['img1']['name']) OR empty($_FILES['img1']['name'])) { $errors['img1'] = '\'Image 1\' is a required field'; $img1 = FALSE; } else { $ext = explode('.',$_FILES['img1']['name']); $ext = $ext[count($ext)-1]; if (!in_array($ext, $allowed)) { $errors['img1'] = '\'Image 1\' accepts only jpg and gif'; $img1 = FALSE; } else { $img1 = $user_id . '-1.' . $ext; } }
  8. Thanks, thats great. Will test and amend it later on to see if I can modify to fullfill my tasks. Cheers,Kurt
  9. Wander,Thanks for your input. That sounds like what I am after, but where would I put the functions to check for max height/width and resize? Still cannot get my head around in how to apply functions to variables. Maybe there is a complete example code somewhere of sth similar?Kurt
  10. It is an upload file in an area where you have to log in with username and password. Would hope folks do not try dodgy stuff, but then hey... What do I know. Check it a bit more in detail. Thanks for the info.Kurt
  11. Saw that, but as I do not know beforehand what image type folks upload am not sure in how to approach (have an array of allowed files)...Kurt
  12. I use a single table as I only want user to upload the max number of files and as I said if they upload a new file into one column to update the relevant column only. With the current system the user can use upload file and upload 100 files from same input. This means not only that there are a lot of rows for that user in table, but also that our server gets cluttered with unnecessary files...Kurt
  13. How do you move files into their permanent location if the varibles have different name (img1, img2, logo)? I use one file ok with: // move the file over if(move_uploaded_file($_FILES['img1']['tmp_name'], "{$images}/{$img1}")) { echo '<p>the file has been uploaded ok</p>'; } else { echo '<p>the file upload did not work</p>'; } Not all fields are nessesary to upload.Kurt
  14. Having a form where user can upload image files (currently just one) I need to test for a maximum height and width and decrease size if it exceeds the limit. In addtion a thumbnail also needs to be created and both put into separate folders. I found few functions, which can resize an image, but am not sure how to put the whole thing into my file. The relevant code currently is: // check for img1if (!isset($_FILES['img1']['name']) OR empty($_FILES['img1']['name'])) { $errors['img1'] = '\'Image 1\' is a required field';$img1 = FALSE;} else {$ext = explode('.',$_FILES['img1']['name']);$ext = $e
  15. Have a simple insert into db table as:$query = "INSERT INTO imgTest (user_id, img1, active) VALUES ('$user_id', '$img1', 'n')";This query creates each time a row the query is executed. I would like to have only one single row per user (later on I will add more fields to table) and if there is already an entry for this particular column to update column with file name and move new file into image folder as usual deleting old file.I move the file as: if(move_uploaded_file($_FILES['img1']['tmp_name'], "{$images}/{$img1}")) { echo '<p>the file has been uploaded ok</p>'; } else {
×
×
  • Create New...