Jump to content

shergold

Members
  • Posts

    95
  • Joined

  • Last visited

    Never

Everything posted by shergold

  1. Hello again, for some reason the uploaded file is not being saved in the specified directory, the code with the move_uploaded_file() function in is being executed. I appriciate any help. <?php include("config.inc.php"); session_start(); if (!isset($_SESSION['user'])){ header("location: login.php"); exit(); } //filepath $filename = $_FILES['file']['name']; $filename = explode(".",$filename); $filename = $filename[0]; $code = uniqid(); $newname = $filename . $code; $domain = $_SERVER['HTTP_HOST']; $link = "$domain/image.php?loc=$newname"; $targetpath = $_SERVER['HTTP_HOST'] . "/imageup/"; $targetpath = $targetpath . $newname; //file restrictions if ( $_FILES['file']['type'] == "image/jpg" || $_FILES['file']['type'] == "image/gif" || $_FILES['file']['type'] == "image/jpeg" && $_FILES['file']['size'] < 1048576 ) { if($_FILES['file']['error'] > 1) { exit ("<center>There has been an error uploading your file:" . $_FILES['file']['error'] . "</center><br />"); } elseif (file_exists($targetpath)) { echo "<center>A file with this name already exists.</center>"; } else { echo basename($_FILES['file']['name']); $filesize = $_FILES['file']['size']/1000; $filesize = number_format($filesize,0); move_uploaded_file($_FILES['files']['tmp_name'],$targetpath); echo "<center>Your file has been succesfully uploaded</center><br />"; echo "<div class=\"upload_info\" align=\"center\">"; echo "<center>File uploaded: " . $_FILES['file']['name'] . "<br />"; echo "File type: " . $_FILES['file']['type'] . "<br />"; echo "File size: " . $filesize . " KB<br />"; echo "Storage location: " . "<a href=\"$link\">$link</a>" . "<br />"; echo "expiry date: "; echo "</div>"; } } else echo "<center><b>Invalid file</b></center>"; ?> Thanks, Shergold.
  2. i just fixed it before you posted, yeah it was the elseif, also you dont need curly bracers if its only one line, curly bracers are only needed when you are executing multiple lines of code. Thanks, shergold.
  3. Please help, i just cant see the errors in it, its getting really frustrating.
  4. anyone?
  5. Hey, can anyone please help me with the following code, it just outputs a blank page each time i execute the page. <?php include("config.inc.php"); session_start(); if (!isset($_SESSION['user'])){ header("location: login.php"); exit(); } //filepath $filename = $_FILES['file']['name']; $code = rand(5,5); $newname = $filename . $code; $link = "<a href=\"localhost/image.php?loc=$newname\""; $targetpath = "/imageup"; $targetpath = $targetpath . basename($newname); //file restrictions if ( $_FILES['file']['type'] == "image/jpg" || $_FILES['file']['type'] == "image/gif" || $_FILES['file']['type'] == "image/jpeg" && $_FILES['file']['size'] < 1048576 ) { if($_FILES['file']['error'] > 1) { exit ("<center>There has been an error uploading your file:" . $_FILES['file']['error'] . "</center><br />"); } elseif (move_uploaded_file($_FILES['uploadedfile']['tmp_name'],$targetpath)) { echo "Your file has been succesfully uploaded <br />"; echo "<div class=\"upload_info\" align=\"center\">"; echo "<center>File uploaded: " . $_FILES['file']['name'] . "<br />"; echo "File type: " . $_FILES['file']['type']; echo "File size: " . $_FILES['file']['size']; echo "Storage location: " . "<a href=\"localhost/image.php?loc=" . uniqid() . "\"</a>"; echo "expiry date: "; echo "</div>"; } } else echo "<center><b>Invalid file</b></center>"; ?> Thanks, shergold.
  6. ah yes thanks allot, it worked, i dont know why i didnt think of that. Thanks allot, shergold.
  7. Hey guys, could anyone please tell me whats wrong with the following? it just keeps redirecting to the login page even when the session is set and isnt destroying the session: if (isset($_SESSION['user'])) { session_start(); session_destroy(); header("location: /login.php?logout=true"); exit; } else { header("location: /login.php"); } ?> Thanks, shergold.
  8. ok thanksallot for both of your replies, ill use javascript for redirect. Thanks again, shergold.
  9. Hello, i was wondering if there is a way to output text before i send the header, for example the same effect as the following ("location: /page.php"); echo "You are now being redirected to the login page."; any solutions will be greatly appriciated, thanks shergold.
  10. The following website will take you through the basics of php, this should be a start. http://www.w3schools.com/php/ Shergold.
  11. I wouldnt try to do it yet until you have atleast the basics down, but to do this you will need to use a MYSQL database to store the users and profies. for file upload look at the following: http://www.w3schools.com/php/php_file_upload.asp it shows you the basic functions for using file upload in php. Good luck, Shergold.
  12. you can use backticks to execute a command and open and start a batch file in php like so: echo `start C:\folder\file.bat`; If you need anymore help just ask and ill try, Shergold.
  13. although if the <br><br></li></b>\r\n is meant to be in the if statement above it use the following code, this has all the fixes in so you can just copy it and paste it over existing: if (file_exists ($row["$rss_thumbnail"])){ echo '<img src=\"images/$rss_thumbnail\">'; echo "<br><br></li></b>\r\n"; } If you have any more problems just ask, shergold.
  14. ok, your problem is that you have placed the html code in php without any tags around them. the <br> <br></li> and the rest have no starting " or echo. it should be like so: echo "<br><br></li></b>\r\n"; also you have placed a semi-colon ";" at the end of the if statement, take the semi colon of like so: if (file_exists ($row["$rss_thumbnail"])) Shergold.
  15. You are not listening to him, file exists is a function... as he has said use it like so: if (file_exists($id["$thumbnail"])); just copy that code delete ure existing code with the if statement on the line and paste that. please listen this time, Shergold.
  16. i don't know then, phpfreaks has an apache board so try there or ask a moderator or admin to move your thread there as you will get much more responses. Good luck, Shergold.
  17. if you want to post your code i can implement it if you like, also you shouldnt have any issues with a flat file database. shergold.
  18. to check if they are using the school email you could use: strstr($email,"@school.edu"); that will check the string for @school.edu, with the $email being the email address that you want checked. Shergold.
  19. Also are you using windows vista if so there is another service that uses port 80 that you need to stop, i have forgot the name ill try to find it now. EDIT: you must also stop the windows service: World Wide Web Publishing on vista as this uses port 80 also. EDIT: Skype also listens on port 80, so if you are using it exit the program before turning on apache. Shergold.
  20. make sure you have IIS turned off in your services, then try and start again. Apache wont work if there is something else using port 80. Shergold.
  21. Ok thanks allot, also is there a php function to move files from one directory to another? edit: i searched in google before i posted but couldnt find one. Thanks again, Shergold.
  22. thanks allot , works perfectly although you did miss the last parenthesis off the if statement by the way for future reference how would i use the * in php? Thanks allot, shergold.
  23. Hey, i was just wondering how i use the asterisk to mean all. for example if i want to do the following if ($file == "*.txt" || $file == "*.exe") unlink $file; I have tried this without success. ??? Thanks, Shergold.
×
×
  • 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.