Jump to content

[SOLVED] how do i select upload directory


cdog1912

Recommended Posts

Any help would be great Thanks.

-------------------------------------------------------------------------------------------

Here the code:

 

<form method="post" enctype="multipart/form-data">

<table width="350" border="0" cellpadding="1" cellspacing="1" class="box">

<tr>

<td>

<input type="hidden" name="MAX_FILE_SIZE" value="2000000">

Upload File:<input name="userfile" type="file" id="userfile">

</td>

</tr>

<tr>

<td>Model Name:<input name="model" type="text" id="model"></td>

</tr>

<tr>

<td>Album Name:<input name="album" type="text" id="album"></td>

</tr>

<tr>

<tr>

<td><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>

</tr>

</table>

</form>

<?php

$uploadDir = 'Images/';

 

if(isset($_POST['upload']))

{

$fileName = $_FILES['userfile']['name'];

$tmpName = $_FILES['userfile']['tmp_name'];

$fileSize = $_FILES['userfile']['size'];

$fileType = $_FILES['userfile']['type'];

$model = $_POST['model'];

$album = $_POST['album'];

$folder = $_POST['f_dirs'];

 

$filePath = $uploadDir . $fileName;

 

$result = move_uploaded_file($tmpName, $filePath);

if (!$result) {

echo "Error uploading file";

exit;

}

 

include 'config.php';

include 'opendb.php';

 

if(!get_magic_quotes_gpc())

{

$fileName = addslashes($fileName);

$filePath = addslashes($filePath);

}

 

$query = "INSERT INTO upload2 (name, size, type, path, model, album ) ".

"VALUES ('$fileName', '$fileSize', '$fileType', '$filePath', '$model', '$album')";

 

mysql_query($query) or die('Error, query failed : ' . mysql_error());

 

$model_name = "INSERT INTO model_info (model_name)".

"VALUES ('$model')";

 

mysql_query($model_name) or die('Error, model_name query failed : ' . mysql_error());

 

$album_name = "INSERT INTO album_info (album_name, model_name)".

"VALUES ('$album', '$model')";

 

mysql_query($album_name) or die('Error, album_name query failed : ' . mysql_error());

 

include 'closedb.php';

 

echo "<br>Files uploaded<br>";

 

}

?>

----------------------------------------------------------------------------------------------

thanks  :)

Link to comment
https://forums.phpfreaks.com/topic/157629-solved-how-do-i-select-upload-directory/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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