Jump to content

Ninjakreborn

Members
  • Posts

    3,922
  • Joined

  • Last visited

Everything posted by Ninjakreborn

  1. I have a upload script I created, that I replicate to handle images. It has always worked, this time I replicated it to accept 4 file uploads at one time. however, it's not working. <?php // get id of property echo "UPLOAD STATUS"; // name program // prepare variables $target = $docroot . "/userimages/"; // prepare target url $file1 = $_FILES['file1']; $file2 = $_FILES['file2']; $file3 = $_FILES['file3']; $file4 = $_FILES['file4']; echo "<hr />"; echo "Status on File 1"; echo "<br />"; // query to see if they are at there max image count $select1 = "SELECT * FROM user_images WHERE userid = '" . $_SESSION['userinfo']['id'] . "';"; $query1 = mysql_query($select1); if (mysql_num_rows($query1) <= 3) { // run query if (!empty($file1['name'])) { // check if file was an attempted upload $tmp_name1 = $file1['tmp_name']; $name1 = $_SESSION['userinfo']['id'] . "_" . $file1['name']; $target1 = $target . $name1; $i1=@getimagesize($file1['tmp_name']); // get image size if (($i1[2]==1) or ($i1[2]==2) or ($i1[2]==3) or ($i1[2]==6)) { // test if proper image type if (file_exists($target1)) { echo "File 1 is already in the database.<br />"; }else { if (move_uploaded_file($tmp_name1, $target1)) { echo "File 1 was moved to temporary memory successfully.<br />"; $insert = "INSERT INTO user_images(userid, imagename) VALUES('" . $_SESSION['userinfo']['id'] . "', '$name1')"; if (mysql_query($insert)) { echo "File 1 upload successfully completed.<br />"; }else { echo "Problem's inserting it into database though.<br />"; } }else { echo "There was a problem uploading this specific file.<br />"; } } // check for image type } else { echo "Improper filetype: File discarded."; } }else { echo "You did not attempt to upload File 1, so no actions were performed.<br />"; } }else { echo "You have uploaded the max amount of file's you are allowed.<br />"; echo "File 1 upload discarded.<br />"; } echo "<hr />"; echo "Status on File 2"; echo "<br />"; // Select from db to make sure they have slot's available to upload new images $select2 = "SELECT * FROM user_images WHERE userid = '" . $_SESSION['userinfo']['id'] . "';"; $query2 = mysql_query($select2); if (mysql_num_rows($query2) <= 3) { if (!empty($file2['name'])) { $tmp_name2 = $file2['tmp_name']; $name2 = $id . "_" . $file2['name']; $target2 = $target . $name2; $i2=@getimagesize($file2['tmp_name']); if (($i2[2]==1) or ($i2[2]==2) or ($i2[2]==3) or ($i2[2]==6)) { if (file_exists($target2)) { echo "File 2 is already in the database.<br />"; }else { if (move_uploaded_file($tmp_name2, $target2)) { echo "File 2 was moved to temporary memory successfully.<br />"; $insert = "INSERT INTO user_images(userid, imagename) VALUES('" . $_SESSION[ 'userinfo']['id'] . "', '$name2')"; if (mysql_query($insert)) { echo "File 2 upload successfully completed.<br />"; }else { echo "Problem's inserting it into database though.<br />"; } }else { echo "There was a problem uploading this specific file.<br />"; } } // check for image type } else { echo "Improper filetype: File discarded."; } } else { echo "You did not attempt to upload File 2, so no actions were performed.<br />"; } }else { echo "You have uploaded the max amount of file's you are allowed.<br />"; echo "File 2 upload discarded.<br />"; } echo "<hr />"; echo "Status on File 3"; echo "<br />"; // Select from db to make sure they have slot's available to upload new images $select3 = "SELECT * FROM user_images WHERE userid = '" . $_SESSION['userinfo']['id'] . "';"; $query3 = mysql_query($select3); if (mysql_num_rows($query3) <= 3) { if (!empty($file3['name'])) { $tmp_name3 = $file3['tmp_name']; $name3 = $id . "_" . $file3['tmp_name']; $target3 = $target . $name3; $i3=@getimagesize($file3['tmp_name']); if (($i3[2]==1) or ($i3[2]==2) or ($i3[2]==3) or ($i3[2]==6)) { if (file_exists($target3)) { echo "File 3 is already in the database.<br />"; }else { if (move_uploaded_file($tmp_name3, $target3)) { echo "File 3 was moved to temporary memory successfully.<br />"; $insert = "INSERT INTO user_images(userid, imagename) VALUES('" . $_SESSION['userinfo']['id'] . "', '$name3')"; if (mysql_query($insert)) { echo "File 3 upload successfully completed.<br />"; }else { echo "Problem's inserting it into database though.<br />"; } }else { echo "There was a problem uploading this specific file.<br />"; } } // check for image type } else { echo "Improper filetype: File discarded."; } } else { echo "You did not attempt to upload File 3, so no actions were performed.<br />"; } }else { echo "You have uploaded the max amount of file's you are allowed.<br />"; echo "File 3 upload discarded.<br />"; } echo "<hr />"; echo "Status on File 4"; echo "<br />"; // Select from db to make sure they have slot's available to upload new images $select4 = "SELECT * FROM user_images WHERE userid = '" . $_SESSION['userinfo']['id'] . "';"; $query4 = mysql_query($select4); if (mysql_num_rows($query4) <= 3) { if (!empty($file4['name'])) { $tmp_name4 = $file4['tmp_name']; $name4 = $id . "_" . $file4['name']; $target4 = $target . $name4; $i4=@getimagesize($file4['tmp_name']); if (($i4[2]==1) or ($i4[2]==2) or ($i4[2]==3) or ($i4[2]==6)) { if (file_exists($target4)) { echo "File 4 is already in the database.<br />"; }else { if (move_uploaded_file($tmp_name4, $target4)) { echo "File 4 was moved to temporary memory successfully.<br />"; $insert = "INSERT INTO user_images(userid, imagename) VALUES('" . $_SESSION['userinfo']['id'] . "', '$name4')"; if (mysql_query($insert)) { echo "File 4 upload successfully completed.<br />"; }else { echo "Problem's inserting it into database though.<br />"; } }else { echo "There was a problem uploading this specific file.<br />"; } } // check for image type } else { echo "Improper filetype: File discarded."; } } else { echo "You did not attempt to upload File 4, so no actions were performed.<br />"; } }else { echo "You have uploaded the max amount of file's you are allowed.<br />"; echo "File 4 upload discarded.<br />"; } ?> File 1, File 2, and File 4 are all working correctly. However, anything that get's loaded into the slow for File 3 give's me the following error What is strange, is again as you can see the file 3 script is a replicate of file 1, file 2, and file 4. They are all the same script. However this one happen's to not be working, any advice, would be greatly appreciated? Thanks.
  2. The server can time out during the upload. What happens, does it go to a blank screen, or loads forever. A 25mb file would take roughly 30-45 minutes on average for a php script to upload, that take's time. 4 fairly large images each less than a meg, can take 5 minutes depending. If not that then most likely the server time'd out.
  3. Incase if it help's anyone I created this <?php function getExtension($file) { $pos = strrpos($file, '.'); if(!$pos) { return 'Unknown Filetype'; } $str = substr($file, $pos, strlen($file)); return $str; } ?>
  4. I am just frustrated because I had an entire file handling system created I recopied, however accidentally deleted the source file's along time ago, and haven't gotten around to building another one. This project is going to require me to rebuild another one, which I am looking for quicker way's to get this up and running. I may just use regular expressions. Thanks for all the advice.
  5. I know, but I am running it through an array. I wanted to know if it's 100% safe. I want to run it through something like. $extensions = array(".wav", ".mov", ".swf"); // plus whatever else will be here foreach ($extensions as $k => $v) { if (strpos($extensions, $file)) { req } ah whatever I will get it together when I get started, but that's the basic idea. I am going to use strpos to validate the filetype's.
  6. Good that is exactly what I wanted to hear. Thanks.
  7. Is strpos() as affective as straight regular expressions for finding a basic string inside another string. For example, validating filetypes (Other filetypes). Say I wanted to allow only .mov, Is strpos checking for mov inside a filetype going to be safe, or testing for .mov. Is this going to be as affective as setting it up to test with regular expressions?
  8. http://cit.ucsf.edu/embedmedia/step1.php I found it, nevermind. THis should do, this is the link someone gave me awhile back (incase anyone else ever need's it), I think it was andy who originally sent me the link. Thanks again.
  9. I want to ask what other people do. If you are requested by a client to allow uploads of video/audio file's what file types do you normally aim for. I created a massive file management system awhile back, trying to do every file type I could imagine. I got up to 70 file extensions that actually worked. I came here on php freaks, and was given a url. That url took me to a place that generated code for a player. The link was to a program. You specify the filetype(s), and it generates the code you would need to use to embed the player into html. For instance you could put .mov, .wav, and whatever it would create the html to embed windows media player. Same if you put in flash file's. I lost that, I was wondering if someone can help me find that link again. It might be "somewhere" still on the forum's. I was also as a secondary question, wondering what filetype's you normally accept when doing file uploads like that.
  10. That is what I was thinking, thanks.
  11. Since the data is all the same, I would think 3 different parts. The question, the answer associated with the question, and a category to put the question under. You want to be able to easily add new question/answer combo's, as well as add new categories. You want to be able to add/edit/delete questions You want to be able to associated/deassociated questions/answers with specific categories. I think that would all be pretty straightforward. The hard part I think would be deciding on the style. How many different style's you would want the system to have. I would then create a folder, have 1 css file for each style you want, and have the ability for someone to change it using a GUI. I would create a GUI for the site itself, an area where people could put in db info, and create the database/tables necessary for it to run, then you can just go back and enter questions/answers and categories as needed. THe system itself, and where everything is, is already setup. Same thing everytime. http://www.sulata.com.pk/greatfaqs/great_faqs/index.php There is something that is already created, to give you an idea of what might be possible. Good luck.
  12. What are the standard opinions on the heredoc statement. I never really liked the way they looked, but by investigating them further, you can throw $variables out in random places and it automatically detects the interpolation, also you don't have to escape double quotes. In your opinion is heredoc, single quotes, or double quote's better.
  13. When you install XXAMP filezilla is installed as well. The default username/password for the ftp server is also set. How do I change that, I don't see anywhere I can change that, and I don't see a way into filezilla itself?
  14. Check a book called Digital Audio Essentials by Bruce Fries, Marty Fries It's something that will cover (among other things) how this can be accomplished in PHP.
  15. What is mercury, it's packaged with XXamp, and a look at google give's me 1-200 different things called mercury?
  16. You were right originally, it ended up being a problem with the array from the very beginning. I am marking this as solved, thanks for the help. You helped me track down the problem.
  17. Yes, it should work however, it's not. Generic tests (ALL numbers) works. Then when I retested, checked on php.net it'sn ot meant to be fullproof. It's not meant to work as a definitive. if you have number's, and hten some letter's it let's it got through depending on the combination. Anybody have something they use that is fullproof?
  18. This whole time I thought it did, the client said he could still enter letter values. I did that, it wasn't working for some reasons letter's are still going through. What is a good way to make 100% sure the value is a number.
  19. You can't hope to make anything decent without some PHP knowledge. If you are looking for "something" there are a lot of them out there. Google for some third party forum scripts in PHP (90% of them have a mysql backend). Try to find something that can work without register global's being on so it's more secure. There is one in particular now that I always use. SMF (simply machines), which is actually the same one they use on phpfreaks. There area lot of other's out there Vbulliten, SMF(Simple Machines), PHPBB, and many other's. In fact you can find a few probable in PHP freaks personal code library or tutorials.
  20. This is what I know about SSL, only the information I have picked up while working. SSL = Secure Socket Layers. There are 2 things involved in an SSL system 1. An SSL certificate - which is a keycode on the server given by a specific place. 2. An SSL Key - what combines with teh certificate to "activate" it. The purpose of an SSL certificate is to prove you are worth something, and trustworty. If a trustworthy company gives you a certificate, that means you are more likely to be trustworthy. That is what an SSL certificate and key are. As far as SSL itself it's an extra part of the url. If you visit http://www.godaddy.com you are on there original page If you visit https://www.godaddy.com you are on there encrypted page. There is a difference, when it has http then the data is requested from the server, the server go through it's processes and serve's the page. WHen it's SSL which is https it does the same thing, except right before it sends it to the browser, it run's it through a program that encrypt's the information during transit, this increases security on a high scale. It's not flawless, but it's better than non-encrypted. However it also adds more overhead to the server so you have to remember to only use it when you need it (when sending sensitive information, or something similar). It's not even really worth using it (in my opinion) for password. More of for things like social security numbers, driver's liscence number's, credit card number's, or other sensitive or important information. PHP programming in SSL it's the same thing. Everything is programmed exactly the same, except if you are doing full url's in your links or references you have to include https instead of http to keep them on the secure connection. I hear with CURL (not 100% sure) you can setup your own SSL using PHP/Curl without having to have an ssl connection (https). That I am not 100% sure of, but everything else in relation to PHP programming on an encrypted (https) website is the same as a standard website seeing that the https doesn't actually "change" anything, it just encrypts the data during transit on a very high level, far more than what you could do with natural programming (I would assume).
  21. Are they going to be furthering the development of any web development languages. You mention they were a collection of companies, does it say a memberslist or another area of people that have joined (companies). That seems interesting.
  22. It has to be in an echo of some sort, or in a variable. Examples <?php // example 1 echo substr_replace($list['CCNO'], "*", 0, strlen($list['CCNO']) - ; // example 2 $temp = substr_replace($list['CCNO'], "*", 0, strlen($list['CCNO']) - ; echo $temp; ?>
×
×
  • 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.