Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

prob with uploaded file directory w php and pws

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

prob with uploaded file directory w php and pws

Postby Hurkle » Tue Jan 07, 2003 8:54 am

Howdy

I'm trying to build a tool to allow users to store any type of file in a database.

I'm building the prototype on my laptop, running php 4.2.1, and mysql 3.23 something.

Here's the problem.. I've built a simple upload form, with a File input form element. I can't figure out how to correctly set the path in php.ini so that my code can find the uploaded files.

If anyone has insight into this, I'm specifically looking for help with the followoing:

1. What is the default upload directory for Personal Web Server, and can it be changed?

2. How do I correctly format the path to this directory in the php.ini file so that my code can get at these files, including any slashes and dots? (I'm *nix challenged when it comes to file names..)

3. Any other info or insights that might apply would be greatly appreciated.

Thx in advance!
Hurkle
New php-forum User
New php-forum User
 
Posts: 36
Joined: Tue Jan 07, 2003 8:45 am
Location: Minnesota, USA

Postby Joan Garnet » Tue Jan 07, 2003 9:08 am

I don't know about pws...
But here you are a script that copies a file into a directory as you want.
Maybe it works in the same way...

Code: Select all
if ( !@copy ( $_FILES['your_file']['tmp_name'] , $dir.$new_name_file) ){ //copy the file from your multipart form data form. "your_file" is the name of the field in the form. $dir is the dir where you want it to be copied (relative to the script) and $new_name_file is the definitive name for the file
            echo "<b>".$file." </b> is not copied !!<b><br>";
         }else{
            echo "<b>".$file."</b> is copied !!";
         }
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

thx for the quick answer, still need help

Postby Hurkle » Tue Jan 07, 2003 9:15 am

Thx for the quick reply, Joan, I do appreciate it.

I've already got a handle on how to process the file once I've got it, I've built and tested that code with files I manually placed into a known directory.

I'm still stuck on letting php know where the uploaded file is, and for that matter, getting the file to upload correctly in the first place.

I think I'm going to have to do some more digging, I might have to set rights on my upload directory, which means I'm going to have to figure out what user the php script engine runs as.

Thx again for your answer!
Hurkle
Hurkle
New php-forum User
New php-forum User
 
Posts: 36
Joined: Tue Jan 07, 2003 8:45 am
Location: Minnesota, USA

Postby Joan Garnet » Tue Jan 07, 2003 10:45 am

Well,
I think it depends on the temp directory you've chosen here:
$tmp_dir = "./some_dir";
$_FILES['$your_file']['$tmp_dir'];


If you've got the default config in your php_ini, it should work.
http://www.zend.com/manual/configuratio ... ad-tmp-dir
Anyway, If you want you can assign it from php_ini as well.

No further explanations about pws were given in the zend website --->
http://www.zend.com/manual/features.file-upload.php
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

Postby Hurkle » Tue Jan 07, 2003 10:53 am

Thx again, Joan!

I figured out what was going on, and where my files were.

The machine I'm prototyping on is a win 98 box w. personal web server, very weak compared to the production environment.

The code snippets I was using as reference were lame, they didn't use the $_FILES['whatever'] format, but something else that wouldn't work right with my setup.

The code that works looks a heck of a lot like what you posted, once again, thx very much for a timely response and your help.

Hurkle
Hurkle
New php-forum User
New php-forum User
 
Posts: 36
Joined: Tue Jan 07, 2003 8:45 am
Location: Minnesota, USA


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.