Jump to content

mrclark219

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mrclark219's Achievements

Newbie

Newbie (1/5)

0

Reputation

  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
×
×
  • 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.