Jump to content

Question????


mrclark219

Recommended Posts

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.';
}

}

Link to comment
Share on other sites

Try something like this:

 

<?php

$dirs = scandir("images/");
foreach ($dirs as $dir) {
if ($dir == '.' or $dir ==  '..')
	continue;

if (is_dir($dir)) {
	$images = scandir("images/$dir");
	foreach ($images as $image) {
		echo '<img src="images/'.$dir.'/'.$image.'" />';
	}
}
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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