Jump to content

Problem with moving files.


kernelgpf

Recommended Posts

My problem is that the code is displaying that the file was successfully uploaded to the directory "/home/www/ffpb2.100webspace.net/pendingimages/$filenamehere", but it really isn't being uploaded. Could somebody point out my problem?

[code]
$afile=$_FILES['file']['name'];
if(!empty($afile)){
//Change this to the directory you would like to upload files to.
//Change these to allowed files types users can upload
$allowedfile[] = "image/gif"; //.gif
$allowedfile[] = "image/pjpeg"; //.jpeg
$allowedfile[] = "image/jpg";  //.jpg
$allowedfile[] = "image/png";  //.png
$allowedfile[] = "image/psd";  //.psd
//Check to see if file exists | If it does, then we stop the process, although if it doesnt then we continue
$fileplace="$v/pendingimages/$afile";
$directory="$v/pendingimages/";
$gfileplace="$v/gallery/$afile";

if(file_exists($gfileplace) == "1") {
$is_uploaded = "failed";
echo 'Sorry! This file already exists. ';
exit(); //If $is_upload = failed, then we stop the uploading process
}
if(!in_array($_FILES["file"]["type"],$allowedfile)) {
$is_uploaded = "failed";
echo 'Sorry! Wrong file type, "'.$_FILES["file"]["type"].'" is not allowed. ';
exit(); //If $is_upload = failed, then we stop the uploading process
}
//Now, if $is_uploaded does NOT = failed, we remove invalid characters in the filename, and replace all spaces with underscores
    if($is_uploaded != "failed") {
        $replace = array("$","%","#","@","!","&","^","*","(",")","-"," ");
        $new = str_replace($replace,"",$_FILES["file"]["name"]);

            //Now we upload the file and check for errors
$variable=$_FILES["file"]["tmp_name"];
            if(move_uploaded_file($variable, $fileplace)){
print "$fileplace";
$imagetitle=$_POST['imagetitle'];
mysql_query("insert into gallerymaybes(filename,imagetitle,submittedby)values('$afile','$imagetitle','$sid')")or die(mysql_error());
print "Image successfully sent in, and if approved, will be added to the gallery. You will earn a gallery point and receive a message for any images accepted.";
                    }
                        else {
        echo 'Error: Uknown Error';
        exit();
        }

[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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