Jump to content

mrclark219

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

Everything posted by mrclark219

  1. Hello all: I have this script that uploads a file. It sends the file to a subdirectory, but if the subdirectory doesn't exist then it creates it. Right now I am trying to create a link to this file on the page in which it corresponds to (in my case this would be parts, so in my directory(secure/parts) it creates a sudirectory for part number 1(secure/parts/0001) Here is the code: // You don't really need basename() here, the name only contains the filename (with extension) (I think) $target = basename($_FILES['uploaded']['name']); // Assuming $fileDest is the base directory for your files // AND Assuming it already has the / on the end of it $dest = $fileDest . $partNumber . '/'; // Make the PartNumber directory if it is not already there if (!is_dir($dest)) { mkdir ($dest, $mode = 0777, $recursive = false); } // Move the uploaded file if (move_uploaded_file($_FILES['uploaded']['tmp_name'], $dest . $target )) { echo "File uploaded!"; } else { $errMsg .= 'An unexpected error has occured. Please try again and contact the Information Management Systems Administrators if the problem persists.'; } } //$secureLoc = '/sites/secure/parts/'; $dest = $fileDest . $partNumber; $handle = opendir($dest . '/'); /* This is the correct way to loop over the directory. */ while (false !== ($file = readdir($handle))) { if(!is_dir($dest . '/' . $file)){ echo "$dest/$file<br>"; } } closedir($handle); Ok so now the way I want this to work is I want to check the directory and tell me what is there which works fine if there has been an upload, but if not I get these nasty error messages. Can anyone tell me what I am missing n where to find it?
  2. Ok, so I am a total newb at php but I have this upload script. It works just fine, it sends the file to the a subdirectory according to a corresponding part number. My question is could anybody point me in the direction of creating some type of link that users can get to the uploaded file from the page where the part number's! Thanks Here is what I have... $target = basename($_FILES['uploaded']['name']); // Assuming $fileDest is the base directory for your images // AND Assuming it already has the / on the end of it $dest = $fileDest . $partNumber . '/'; // Make the PartNumber directory if it is not already there if (!is_dir($dest)) { mkdir ($dest, $mode = 0777, $recursive = false); } // Move the uploaded file if (move_uploaded_file($_FILES['uploaded']['tmp_name'], $dest . $target )) { echo "File uploaded!"; } else { $errMsg .= 'An unexpected error has occured. Please try again and contact the Information Management Systems Administrators if the problem persists.'; } }
  3. Thanks a million David!! Works fine now all I need now is to create a link to the file on the page that displays the part number and I am done! I really appreciate the help!!
  4. Im researching move_uploaded_file on php.net and it says Above is the script that I created to move the uploaded file to $dest which is all laid out in this discussion forum. Here are the errors that I get when I click submit on the upload form to submit the file test.txt.. The last error messages doesn't really bother me that much as it is just letting me know that the directory for that given part number has been created. I'm in need of some assistance. Can someone tell me what minor detail I have overlooked to resolve this matter TODAY! I would really appreciate your assistance in handling this tasks. Im out of ideas.. Thank you Thomas Clark
  5. Thanks for the help...I get this error now : move_uploaded_file(/usr/local/apache/sites/secure/parts/00001uploaded/) [function.move-uploaded-file]: failed to open stream: Is a directory in /var/www/dev.neoterichovercraft.com/neoteric/code/inventory/upload.php on line 65. Does this mean that I dont have the right permissions set? Here is the code I have now: $target = $fileDest . basename( $_FILES['uploaded']['name'] ) ; $ok=1; $dest = $fileDest . "$partNumber" . "$file/"; if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $dest )) { echo "File uploaded!"; } else { $errMsg .= 'An unexpected error has occured. Please try again and contact the Information Management Systems Administrators if the problem persists.'; } } if (file_exists($fileDest)){ mkdir ($fileDest .$partNumber . "$file/", $mode = 0777, $recursive = false); } else{ echo 'Error occurred contact System Manager!'; } if (!move_uploaded_file($_FILES['uploaded']['tmp_name'], $dest)){ move_uploaded_file($file, $dest); } This produce the failed to open stream error..Any ideas?
  6. Do you know where I could find sufficient documentation on this. I have been searching but I have run across anything that solves my problem. I am not 100 percent sure on this, I know there has to be something somewhere. I have been stuck on this for about three days. It's long overdue!!
  7. Thanks for the help, I took what you said to use and came up with this: if (file_exists($fileDest)) mkdir ($fileDest .$partNumber . "$file", $mode = 0777, $recursive = false); else{ echo "Error occurred contact System Adminstrators!"; } Now my problem is that the directory is created and the file is uploaded but the file doesn't go into the subdirectory. I have created a spot /usr/local/apache/sites/secure/parts/ which is $fileDest and the mkdir code creates the subdirectory inside the above. How do I merge the two together so that all uploads just go straight to the corresponding subdirectory? I know it is something very small that I am overlooking but I think Im getting closer to resolving this problem. Any ideas of what I could do differently?
  8. Hey guys need some help with some code I have been playing with..Here is my problem I have this upload script that I made it works but I need to make some revisions to this and I am not 100 percent sure how to do it. $target = "/usr/local/apache/sites/secure/parts/"; $target = $target . basename( $_FILES['uploaded']['name'],$partNumber) ; $ok=1; if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded"; } else { $errMsg .= 'An unexpected error has occured. Please try again and contact the Information Management Systems Administrators if the problem persists.'; } Here is my question I have created a place for this upload to go as you can see the $target, but how can I revise this to work in a way that indexes each upload by part number? For example if I upload the file test.txt to part number 15 could it create a subdirectory for the different partnumber files to go? Does that make sense? I want to have all files to go with there corresponding part number but if the subdirectory doesn't exist I would like it to be created. Please help!!
  9. I still haven't gotten this resolved I tried using the advice given here, but nothing happened..Any more suggestions, Im totally lost now!
  10. I appreciate the advice but I am a complete and utter newb at this, so I need it broken down just a little more. Im sorrry if this is causing any problems but I need to get this handled, rather quickly!
  11. OK so I created this table pulling data from my mysql database. But since the database is very large it pulls a bunch of data making an already cluttered page even worse. My question is, is there a way using php or any other languages that would work well together that I can create a show/hide button that would hide this table until someone needed it! Please someone help me out! Thanks for the time ...I am told that you can only do this with JavaScript and Im far from being an expert in either of the languages here , but I really need to get this knocked out any suggestions, examples would be great be im stomped....and here is the coding for the table $xmlDoc->addTable($stock->addRelation('purchaseOrders')->getData(array('purchaseOrders.dbPurchaseOrderNumber', 'purchaseOrders.dbPurchaseDate', 'purchaseOrders.dbReceived', 'purchaseOrderParts.dbQuantity'), NO_PRIMARY_KEY,'purchaseOrderParts.dbPartNumber="' . $partNumber . '" ORDER BY purchaseOrders.dbPurchaseDate DESC LIMIT 10'), CONTENT_NODE, array('TABLE'=>array('SHOW_HEADER'=>'1', 'LABEL'=>'Purchase Orders'))); if(!$stock->addRelation('purchaseOrders')->numRows) $xmlDoc->addData('No results found', $dataTag); $xmlDoc->addTag('HR', $hrTag);
  12. I would really love an example of this if anyone has the time?
  13. At this point I just want it done, so that I can move, but I find myself stuck right here where I am...I'm relatively new to php, and I have kind of just been learning as I go along, but this one has me completely stumped and the way u guys are talking it seems relatively easy...I just cant figure it out!
  14. OK so I created this table pulling data from my mysql database. But since the database is very large it pulls a bunch of data making an already cluttered page even worse. My question is, is there a way using php or any other languages that would work well together that I can create a show/hide button that would hide this table until someone needed it! Please someone help me out! Thanks for the time, and here is the coding for the table... $xmlDoc->addTable($stock->addRelation('purchaseOrders')->getData(array('purchaseOrders.dbPurchaseOrderNumber', 'purchaseOrders.dbPurchaseDate', 'purchaseOrders.dbReceived', 'purchaseOrderParts.dbQuantity'), NO_PRIMARY_KEY,'purchaseOrderParts.dbPartNumber="' . $partNumber . '" ORDER BY purchaseOrders.dbPurchaseDate DESC LIMIT 10'), CONTENT_NODE, array('TABLE'=>array('SHOW_HEADER'=>'1', 'LABEL'=>'Purchase Orders'))); if(!$stock->addRelation('purchaseOrders')->numRows) $xmlDoc->addData('No results found', $dataTag); $xmlDoc->addTag('HR', $hrTag);
  15. Hello all, I am fairly new to the php world and I created a table from my mysql database, but the table is extremely large. I need a way to make this table collapsible. Sort of like a show/hide type feature. Is this possible? Any help would be greatly appreciated!! This is the code I used to pull the data from the database, not sure if that will help at all but its worth the try! $xmlDoc->addTable($stock->addRelation('purchaseOrders')->getData(array('purchaseOrders.dbPurchaseOrderNumber', 'purchaseOrderParts.dbVendorNumber', 'purchaseOrders.dbPurchaseDate', 'purchaseOrders.dbReceived', 'purchaseOrderParts.dbQuantity'), NO_PRIMARY_KEY,'purchaseOrderParts.dbPartNumber="' . $partNumber . '" ORDER BY purchaseOrders.dbPurchaseDate DESC LIMIT 100'), CONTENT_NODE, array('TABLE'=>array('SHOW_HEADER'=>'1', 'LABEL'=>'Purchase Orders'))); if(!$stock->addRelation('purchaseOrders')->numRows) $xmlDoc->addData('No results found', $dataTag); $xmlDoc->addTag('HR', $hrTag); Thanks, Thomas Clark
  16. This is totally not the case I just can't seem grasp what I am doing wrong I tested without the is numeric and it is worse than before. At least with it there the page would load and what not without it I can't even get to the page. I really don't understand what is going on?
  17. And that is supposed to mean what? I never said I was a php freak! Can you help me out or not? If not leave the rude comments at the door! Thanks!!
  18. Yes, for a real site! the code was already in play so I'm guessing they have all of that done already a problem with Mastercards messes up the system so I am supposed to see that all places on the site encrypt and decrypt the same way to prevent the errors, so far I have just have This is bad data where the card number should go, I was just wondering if I use uncrypted = 'This is bad data', can I switch that to make it return the number instead of this text? Any idea, as it seems like you may be a guru at this php thing! I need your help because I am not a guru..lol?
  19. Yeah, ok so I removed the md5 from the encrpyt and it made an err through the whole system, I'm not sure why, but I know it wasn't doing it at first...I've only been learning php for about a month, now so I am very confused as to why this won't work, I think i need a different value for uncrypted in the decrypt part, but I am not exactly sure what this would be to return the card numbers in the system because now it just returns This is bad data...please help!!!
  20. So, you are saying that I can't use this to return the original card number? What would you recommend?
  21. A credit card number...I probably should have posted the encryption function as well. I need the function that decrypts to return the actual card number instead of this is bad data, but I got lost along the way and it wasnt working...here is the encryption function! function encrypt($tring, $contactNumber) { $tring = str_replace(' ', '', $tring); $key = md5($contactNumber); $ivSize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); $iv = mcrypt_create_iv($ivSize, MCRYPT_RAND); $crypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $tring, MCRYPT_MODE_ECB, $iv); return $crypted; Thomas Clark
  22. Hey guys, Im relatively new at this php thing so I need some help from you guys. I am doing cc encryption and decryption using the md5 hash, so far I have gotten the encryption to work, but as far as the decryption it just doesn't work...take a look at what I've got! function decrypt($tring, $contactNumber){ $key = md5($contactNumber); $ivSize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB); $iv = mcrypt_create_iv($ivSize, MCRYPT_RAND); $uncrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $tring, MCRYPT_MODE_ECB, $iv); if(!is_numeric($uncrypted)); $uncrypted = 'This is bad data'; return trim($uncrypted); I need a value for uncrypted to make it return the number instead of this is bad data any ideas? any help would be appreciated!! Thomas Clark
×
×
  • 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.