|
Posted by Jochem Maas on 08/14/05 00:48
<< z a p a n >> wrote:
> hello,
>
> sorry in advance if my question is naive.. i'm trying to allow file
> uploads. optimally i'd like to store these files (jpgs, mostly) directly to
> a folder in my httpdocs.. i've heard something about file uploads not being
> allowed if server is set to safemode.. not sure why but i've been getting
don't know if that is true - but then you don't say whether the machine your on
is running in safe_mode.
you don't even say what errors - why don't you present some output from your script,
no point in anyone running it somewhere else really is there?
******
oh and DONT post a new question as a reply to an existing thread - bad bad bad.
******
most probably your script (or rather the user it is running as - most likely something
like 'apache' else the user account given to you on the box in question) doesn't have
write permissions for the dir you want to move the upoaded files to.
or maybe the directory /release_pics/ doesn't even exist, $uploads_dir
need to contains path not a halfbaked URL - I'm assuming that your document root
is not / ... so try something like:
$uploads_dir = '/PATH/TO/YOUR/WEB/DOCUMENT/ROOT/release_pics/';
btw you have to replace the '/PATH/TO/YOUR/WEB/DOCUMENT/ROOT' bit with
something valid ;-)
oh and try checking the return values of functions (e.g. move_uploaded_file)
- they might give you a hint. also check your error logs and start using
functions like print_r(), var_dump() to see what's going on inside your script...
> errors.. here're the two files if you have time to check them out. thanks
> for your time!
>
> xo, -z
> ----------
> [file1.html]
>
> <form enctype="multipart/form-data"
> action="file2.php" method="post">
> <input type="hidden" name="MAX_FILE_SIZE" value="10000000">
> FILENAME: <input name="filename1" type="file"><br><input type="submit"
> value="submit"></form>
>
>
> ----------
> [file2.php
>
> <?php
> $uploads_dir = '/release_pics/';
> foreach ($_FILES as $myfile) {
> $filename = $myfile['name'];
> switch ($myfile['error']) {
> case 4:
> continue 2;
> case 1:
> case 2:
> print "sorry, $filename is too big.<br>";
> continue 2;
> case 3:
> print "the upload of file $filename was broken. please try again.<br>";
> continue 2;
> }
> print "received: $filename.";
> print "type: $myfile['type'].<br>";
> move_uploaded_file(
> $myfile['tmp_name'],
> $uploads_dir.$myfile['name']);
> }
> ?>
>
>
Navigation:
[Reply to this message]
|