Jump to content

Upload Help


EKsparky

Recommended Posts

I've got a basic upload script

The idea is that you upload a picture to an album

So i keep the script in galleries dir

now in that dir there are other folders each of these is an album

examlpe folder1 folder2 folder3

now my script works fine if i just upload to galleries but when i try to add an album var to the path it goes wrong

It still up loads the picture but places it in galleries folder and rename the picture

Example i upload ME.jpg it will appear in the galleries folder as folder1ME.jpg

Heres my code

<h3>File Upload</h3>
Select a file to upload:<br>

<form action="uploader.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" size=50>
<br>
Choose album:
  <input name="choose_album" type="text"><br>
<input type="submit" value="Upload File"><br>
</form>

 

<?php 	

$A_path = $_POST['choose_album'];
if($_FILES['file']['name'] !="")
{
  copy ($_FILES['file']['tmp_name'], "galleries/$A_path".$_FILES['file']['name']) or die("Could not copy file");
}
else
{
  die("No file specified");
}

?>

<html>
<head> <title>Upload complete</title> </head>
<body>
<h3>File upload succeeded...</h3>
<ul>
<li>Sent: <?php echo $_FILES['file']['name']; ?>
<li>Size: <?php echo $_FILES['file']['size']; ?> bytes
<li>Type: <?php echo $_FILES['file']['type']; ?>
</ul>
<?php echo ''.$A_path.''; ?>
<a href="<?php echo 'galleries/$A_path'.$_FILES['file']['name']; ?>">Click here to view file</a> 
</body>
</html>

 

Now echo $A_path  near the bottom will infact echo album name

so i was thinking maybe i am missing some punctuation in the 2 lines with the path

Thanks

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.