class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
$folder="/domains/mysite.com/public_html/main/staff/images/pets/";
if(ftp_chmod($conn_id, 0777, $folder)) {
// we create an instance of the class, giving as argument the PHP object
// corresponding to the file field from the form
// All the uploads are accessible from the PHP object $_FILES
$handle = new Upload($_FILES['my_field']);
// then we check if the file has been uploaded properly
// in its *temporary* location in the server (often, it is /tmp)
if ($handle->uploaded) {
// yes, the file is on the server
// below are some example settings which can be used if the uploaded
// file is an image.
$handle->file_new_name_body = $_POST["name"];
$handle->image_resize = true;
$handle->image_y = 60;
$handle->image_ratio_x = 100;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = 80;
// now, we start the upload 'process'. That is, to copy the uploaded file
// from its temporary location to the wanted location
// It could be something like $handle->Process('/home/www/my_uploads/');
$handle->Process("".$folder."");
// we check if everything went OK
if ($handle->processed) {
// everything was fine !
ftp_chmod($conn_id, 0755, $folder);
ftp_close($conn_id);
header("Location: true.php");
exit;
} else {
$errors= $handle->error;
mail('mymail@mysite.com','errors',$errors);
ftp_chmod($conn_id, 0755, $folder);
ftp_close($conn_id);
// one error occured
header("Location: false.php");
exit;
}
}
}
I think the error is in the /tmp directory that I don't have. Is the directory that you talk about in your commented code:
// then we check if the file has been uploaded properly
// in its *temporary* location in the server (often, it is /tmp)
I think the error is in the /tmp directory that I don't have. Is the directory that you talk about in your commented code:
Can you help me?
Thank you