Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Uploading to a Directory

Featured Replies

Hey guys

 

Simple question. I have an image upload form which submits to a directory. All works fine...but I want the script to allow the end user to select which directory they want it submitting to.

 

At the moment it submits to a standard uploads/ folder. So I've added in a dropdown menu with the directory selections.

 

Question: How do I feed this information into the uploader.php script? I've had a go at replacing:

 

$target_path = "uploads/"; for this $target_path = $list +[/];

 

Any help would be much appreciated and as you can probably guess I'm a beginner at this!

 

Cheers!

 

Upload.php

 

<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<label>list
<select name="list" id="list">
 <option value="option1">option1</option>
 <option value="option2">option2</option>
</select>
</label><br />
Choose a file to upload: 
<input name="uploadedfile" type="file" /> <input type="submit" value="Upload File" />
</form>

 

Uploader.php

 

 

<?php
$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
" has been uploaded. <a href=\"members.php\">Go Back</a>";
} else{
echo "There was an error uploading the file, please try again!";
}
?>

Hi Josh,

 

change:

$target_path = "uploads/";

 

to

 

$target_path = $_POST['list'] .'/';

 

so that the form field called 'list' is used for the location.

 

I would personally avoid using names like list as it is a function name as well.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.