Sublime directory Surf the web anonymous Pagerank Monitor


[Solved] Custom path?

konkapp
Thu 11 January 2007, 07:11 pm GMT +0200
Nevermind, finally made it to work.

Hi,

I'm trying to make a more generic upload page, based on the example file but...

I want the path to change depending on the querystring of the page.

I tried setting the paths on an array and then setting the upload_dir from it but it didn't work.

$pathh[1] = "../images/products1/";
$pathh[2] = "../images/products2/";

$my_upload = new file_upload;

$my_upload->upload_dir = $pathh[$colname_cc];

I tried using if statements, didn't work either.

Every time time I get the error that the directory does not exist.
When I set the make dir option to true, it seems that its trying to make a dir.. nowhere! Here's the debug:

Warning: mkdir() [function.mkdir]: No such file or directory in /Library/WebServer/Documents/mysite/upload_class/upload_class.php on line 150

Warning: move_uploaded_file(1168535720.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /Library/WebServer/Documents/mysite/upload_class/upload_class.php on line 130

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/var/tmp/phpNiFkAV' to '1168535720.jpg' in /Library/WebServer/Documents/mysite/upload_class/upload_class.php on line 130

Any suggestions? Thanks

Mind_nl
Thu 11 January 2007, 08:19 pm GMT +0200
Good to hear you got it working! What about sharing the solution to your problem, so other people with the same problem can find the solution here?

Oh and welcome to the forums!

konkapp
Thu 11 January 2007, 08:39 pm GMT +0200
Now that i'm 100% sure that it really works after testing >:D here it is:

You dont set the path prior to submitting the form so the code should look like this:

Delete the my_upload->upload_dir reference and place it inside the if clause

if(isset($_POST['Submit'])) {

$my_upload->the_temp_file = $_FILES['upload']['tmp_name'];
$my_upload->the_file = $_FILES['upload']['name'];
$my_upload->http_error = $_FILES['upload']['error'];
$my_upload->replace = (isset($_POST['replace'])) ? $_POST['replace'] : "n"; $my_upload->do_filename_check = (isset($_POST['check'])) ? $_POST['check'] : "n"; $new_name = (isset($_POST['name'])) ? $_POST['name'] : "";

// Place whichever html form element and simply post its value.
// For my case, it is a list box, populated from a recordset.
// The list box value is the path e.g. "../images/products1/"

$my_upload->upload_dir = $_POST['updir'];


$my_upload->upload($new_name);
}

That simple!

olaf
Thu 11 January 2007, 08:41 pm GMT +0200
?

great that your snippet is working now!

Archive for SMF v1.00 by N.P. Valid XHTML 1.0 Transitional