Jump to content

Upload script


kyleldi

Recommended Posts

Hi Everyone,

 

What i'm attempting to do is create a PHP script that will upload an image and its thumbnail to a category folder based on the input of the form.  If a subcategory is selected, the script is supposed to create the sub folder if it doesn't exist, and copy the files to the appropriate place.  Can anyone see what i've done wrong?  The error I get is

 

Parse error: syntax error, unexpected T_IF in gallery/galleryupload.php on line 34

 

This line is

 if(!file_exists(categories/$category/$subcategory)) mkdir(categories/$category/$subcategory, 0755);

 

Here's my code:

 

<?php
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','title');
pt_register('POST','description');
pt_register('POST','category');
pt_register('POST','subcategory');
$thumb=$HTTP_POST_FILES['thumb'];
pt_register('POST','thumbresx');
pt_register('POST','thumbresy');
$blowup=$HTTP_POST_FILES['blowup'];
pt_register('POST','blowupresx');
pt_register('POST','blowupresy');
pt_register('POST','dateadded');
if($title=="" || $category=="" || $thumb=="" || $thumbresx=="" || $thumbresy=="" || $blowup=="" || $blowupresx=="" || $blowupresy=="" || $dateadded=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if(!is_uploaded_file($HTTP_POST_FILES['thumb']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['thumb']['name'].", was not uploaded!";
$errors=1;
}
if(!is_uploaded_file($HTTP_POST_FILES['blowup']['tmp_name'])){
$error.="<li>The file, ".$HTTP_POST_FILES['blowup']['name'].", was not uploaded!";
$errors=1;
}
if($errors==1) echo $error;
else{

if(!file_exists(categories/$category)) mkdir(categories/$category, 0755);

if($subcategory==""
if(!file_exists(categories/$category/$subcategory)) mkdir(categories/$category/$subcategory, 0755);

$image_part = date("")."".$HTTP_POST_FILES['thumb']['name'];
$image_list[4] = $image_part;
copy($HTTP_POST_FILES['thumb']['tmp_name'], "categories/$category/$subcategory".$image_part);
$image_part = date("")."".$HTTP_POST_FILES['blowup']['name'];
$image_list[7] = $image_part;
copy($HTTP_POST_FILES['blowup']['tmp_name'], "categories/$category/$subcategory".$image_part);

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.